0

I'm working at an Angular (v.4) project and using Protractor I bumped into this issue

From the terminal:

I/launcher - Running 1 instances of WebDriver

I/hosted - Using the selenium server at http://localhost:4444/wd/hub Started No specs found Finished in 0.003 seconds

I/launcher - 0 instance(s) of WebDriver still running [17:06:38] I/launcher - chrome #01 passed

It runs the browser which get closed quickly, and it doesn't run (find) any spec.

protractor.conf.js:

require('ts-node/register');
var helpers = require('./helpers');

exports.config = {
  baseUrl: 'http://localhost:3000/',

  // use `npm run e2e`
  specs: [
    helpers.root('test/e2e/**/**.e2e.ts'),
    helpers.root('test/e2e/**/*.e2e.ts')
  ],
  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 110000,

  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
    defaultTimeoutInterval: 400000
  },

  directConnect: true,

  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ["--headless", "--disable-gpu", "--window-size=800x600"]
    }
  },

  onPrepare: function () {
    browser.ignoreSynchronization = true;
  },

  /**
   * Angular 2 configuration
   *
   * useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
   * `rootEl`
   */
  useAllAngular2AppRoots: true
};

Folder structure

-/App
|--/config
   |--protractor.conf.js
   |--helpers.js 
   |--(all webpack files)
   |--(other stuff)
|--/node_modules
|--/src
|--/test
   |--/e2e
      |-mytest.e2e.ts
   |--/features
   |--/mockBackend
   |--/pages
      |-mypage.page.ts
   |--config.js

package.json

"cucumber": "^2",
"cucumber-html-reporter": "^3.0.4",
"cucumber-snippets-tsflow": "^1.0.2",
"cucumber-tsflow": "^2.2.0",
"protractor": "^5.1.2",
"protractor-cucumber-framework": "^3",
"protractor-snapshot": "^1.2.0",
Donovant
  • 3,091
  • 8
  • 40
  • 68

2 Answers2

1

I Just recognized you probably execute npm run e2e as start command, indicating you're using angular-cli or similar to run protractor. Therefore there could be issues in the run-command rather than in the path definition. As far as I could see there were some changes/issues in the way, protractor got started, i.e. here.

I suggest to try these:

  1. put your specs-part inside the capabilities: { ... }-part as this is offered by protractor. Maybe one of the angular-cli-configuration expects the there and not as a separate part
  2. Use a config-helper-tool like Cliptor.js to create a new config-file and then compare for the differences to your file.
  3. Start Protractor directly by executing the command protractor protractor.conf.js (from the official protractor site) instead of npm run e2e to verify/falsify if the problem is within angular-cli or within protractor.
Ernst Zwingli
  • 1,402
  • 1
  • 8
  • 24
0

Any path starts from where protractor.conf.js is stored (so you start in the config-folder). Given the provided folder structure, I'll start with the normal path:

// use `npm run e2e`
specs: [
    //one level up, then below test/e2e/ all files ending with '.e2e.ts'
   // '../test/e2e/**/**.e2e.ts', //if *.ts is a file, no need for double ** 
    '../test/e2e/**/*.e2e.ts'  
],
exclude: [],

in case **.e2e.ts represents a folder and not a file your path should end /**e2e.ts/*.js (or whatever file-ending you chose for the test-file itself).

Also your helpers.js-file you should get as var helpers = require('./helpers.js');

And as I can't see, what's behind this.root I can't provide something for helpers.root()

Further could you want to use TestSuites or you might want to build a helper function, in which you can start from base-directory instead of relative-path to conf.js. Check out these links:

Test Suites vs specs.

baseDir instead of relative path.

Hope I could help.

Ernst Zwingli
  • 1,402
  • 1
  • 8
  • 24
  • **./helpers** is a js file inside **ProjectFolder/config/** folder – Donovant Oct 03 '17 at 08:58
  • Did you then try `var helpers = require('./helpers.js');`? Also what is the content of `this.root` in this case? – Ernst Zwingli Oct 03 '17 at 09:06
  • Yes and I get same error, I also tried with a normal path **specs:['./test/e2e/**/*.e2e.ts']**, nothing still getting that "error" – Donovant Oct 03 '17 at 09:13
  • Is your test-folder inside your config-folder? For normal path you start from the place of your conf.js. `specs:['../test/e2e/**/*.e2e.ts']` – Ernst Zwingli Oct 03 '17 at 09:22
  • I added the folder structure and a part of package.json relevant Protractor and Cucumber – Donovant Oct 03 '17 at 10:05
  • I edited my answer. Can you check, if it works for you now? – Ernst Zwingli Oct 05 '17 at 15:15
  • How do you run it? `npm protractor conf.js`? Do you have access to the folders, where you execute the tests and are the files available to you? Can you add `console.log('this conf.js is executed')` to onPrepare to ensure the right file is called to start it all? – Ernst Zwingli Oct 05 '17 at 19:41