1
votes

I am setting up what I THINK is a simple e2e test for my Angular 8 app. I am trying to learn BDD, so I tried swapping out Jasmine for Cucumber since it uses language more consistent with BDD.

When I run Protractor using Jasmine, the test passes:

this works:

navigateTo () {
    return browser.get(browser.baseUrl) as Promise<any>;
}

When I run a cucumber version of the test, I get an error.

this fails:

  Given ('Evidentia4 is running', (done) => {
           browser.get (browser.baseUrl)
          .then (done ());
  });

"Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined."

The protractor config:

exports.config = {
  allScriptsTimeout: 61000,
  getPageTimeout: 60000,
  specs: [
    './src/features/**/*.feature'
  ],
  capabilities: {
    browserName: 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),
  cucumberOpts: {
    require: 'features/step-definitions/app-step-definitions.js',
    tags: false,
    format: 'node_modules/cucumber-pretty',
    profile: false,
    'no-source': true
  }
};

I've read up on the error but have no idea why I am getting it.

1

1 Answers

0
votes

Can you check if the AngularTestability API's is_stable flag is true or not. If it is true, please check how long it takes to become true. Sometimes it takes longer for Angular Webpage to become stable. Protractor uses the is_stable flag to sync with the page. You can try switching it off (not advised for angular pages) but give it a shot to pin point the error. You can do it by explicitly setting browser.ignoreSynchronisation = true. Now your tests will not wait for Angular promises to resolve. If this works, then you should see how long its taking the is_stable flag to turn true. Sometimes there can be a third party application that is causing the webpage not to be stable. Note that an angular webpage is stable only when all the promises are resolved. If that is the case, you can just wait for the page to be stable before the test execute.

The reason it is working in jasmine and not in cucumber is weird though. Maybe cucumber executes faster than jasmine. I'm not sure though.

Also please set SELENIUM_PROMISE_MANAGER to false in your browser so that you know if you are missing any promises.