abhishekswain / jasmine2-protractor-utils

Utilities for Protractor with jasmine2 [HTML Reports, Screenshot, Browser Console log]
MIT License
18 stars 31 forks source link

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

Open segrey opened 6 years ago

segrey commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Previously, there was a similar issue reported (https://github.com/abhishekswain/jasmine2-protractor-utils/issues/19).

JochenDiekenbrock commented 4 years ago

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

faxus commented 4 years ago

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 commented 3 years ago

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