Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: jasmine is not defined when using with other plugins #25

Open
segrey opened this issue Apr 27, 2018 · 5 comments
Open

Comments

@segrey
Copy link

segrey commented Apr 27, 2018

To reproduce the issue, create these files:

// tests/conf.js
exports.config = {
  framework: 'jasmine',
  specs: ['spec.js'],
  capabilities: {
    browserName: 'chrome'
  },
  plugins: [{
    package: 'jasmine2-protractor-utils',
    disableHTMLReport: false,
    disableScreenshot: false,
    screenshotPath: './reports/screenshots',
    screenshotOnExpectFailure: true,
    screenshotOnSpecFailure: true,
    clearFoldersBeforeTest: true,
    htmlReportDir: './reports/htmlReports',
    failTestOnErrorLog: {
      failTestOnErrorLogLevel: 900,
      excludeKeywords: ['keyword1', 'keyword2']
    }
  }, {
    package: __dirname + '/my-plugin.js'
  }]
};
// tests/my-plugin.js
exports.setup = function() {
    return global.browser.getProcessedConfig().then(function (config) {
        console.log(JSON.stringify(config));
    });
};
// tests/spec.js
describe('empty suite', function () {
    it('with passed test', function () {
    });
});
// package.json
{
  "scripts": {
    "update-webdriver-manager": "webdriver-manager update",
    "run-protractor-tests": "protractor tests/conf.js"
  },
  "devDependencies": {
    "protractor": "^5.3.1",
    "jasmine2-protractor-utils": "^1.3.0"
  }
}
  1. Run "npm install"
  2. Run "npm run update-webdriver-manager"
  3. Run "npm run run-protractor-tests"

Test run fails with the following output:

> @ run-protractor-tests /home/segrey/temp/simple-jasmine2-protractor-utils
> protractor tests/conf.js

(node:25231) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[01:31:15] I/launcher - Running 1 instances of WebDriver
[01:31:15] I/local - Starting selenium standalone server...
[01:31:15] I/local - Selenium standalone server started at http://192.168.1.189:34800/wd/hub
[01:31:17] E/launcher - jasmine is not defined
[01:31:17] E/launcher - ReferenceError: jasmine is not defined
    at /home/segrey/temp/simple-jasmine2-protractor-utils/node_modules/jasmine2-protractor-utils/index.js:50:48
    at ManagedPromise.invokeCallback_ (/home/segrey/temp/simple-jasmine2-protractor-utils/node_modules/selenium-webdriver/lib/promise.js:1376:14)
    at TaskQueue.execute_ (/home/segrey/temp/simple-jasmine2-protractor-utils/node_modules/selenium-webdriver/lib/promise.js:3084:14)
    at TaskQueue.executeNext_ (/home/segrey/temp/simple-jasmine2-protractor-utils/node_modules/selenium-webdriver/lib/promise.js:3067:27)
    at asyncRun (/home/segrey/temp/simple-jasmine2-protractor-utils/node_modules/selenium-webdriver/lib/promise.js:2974:25)
    at /home/segrey/temp/simple-jasmine2-protractor-utils/node_modules/selenium-webdriver/lib/promise.js:668:7
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
[01:31:17] E/launcher - Process exited with error code 199
@segrey
Copy link
Author

segrey commented Apr 27, 2018

Looks like the problem is that jasmine global is accessed from protractor's setup method here: https://github.com/abhishekswain/jasmine2-protractor-utils/blob/1.2.8/index.js#L47
However, according to the documentation setup method is called before the test framework has been set up.

@segrey
Copy link
Author

segrey commented Apr 27, 2018

Previously, there was a similar issue reported (#19).

@JochenDiekenbrock
Copy link

Can this error somehow be avoided?
I'm using
"jasmine2-protractor-utils": "1.3.0"
"protractor": "5.4.2",

@faxus
Copy link

faxus commented Dec 30, 2019

This is still an issue.
Did anyone find a solution?

"jasmine-core": "^3.5.0", "jasmine-reporters": "^2.3.2", "jasmine2-protractor-utils": "^1.3.0",

@gruckionvit
Copy link

This is an issue for me. I've documented my setup here
https://gist.github.com/solkaz/ead11515e2aa91d0dc04e609b3108841

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants