0
votes

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",
2
Yes, nothing to doDonovant
No mate, because helpers.root() resolves pathsDonovant
ok well forget the helpers.root, its not working. Get the basics working first. are you telling me hardcoding ../test/e2e/**/*.e2e.ts without helpers.root does not work??Gunderson
yes, nothing to doDonovant
oh sorry i misread the folder structure. There is no directory under e2e, any different with ../test/e2e/*.e2e.ts?. Deleted above comments to make room for theseGunderson

2 Answers

1
votes

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.
0
votes

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.