Embarking on the journey of setting up Protractor-Cucumber tests, I have established a basic setup following online tutorials shared by a kind Samaritan.
However, upon attempting to run the tests, I encountered an error - unexpected token for the imports. I am puzzled by this issue and would greatly appreciate any assistance.
For reference, the versions of node and other tools I am using are as follows:
C:\Users\A>npm --version
6.4.1
C:\Users\A>node --version
v10.15.1
C:\Users\A>protractor --version
Version 5.4.2
Here is a snippet from my feature file:
Feature: Go to the home
Display the title
Scenario: Home Page
Given I am on the home page
When I do nothing
Then I should see the title
And here is a snippet from my steps definition file:
import { AppPage } from '../pages/app.po';
import { Before, Given, When, Then } from 'cucumber';
import { expect } from 'chai';
let page: AppPage;
Before(() => {
page = new AppPage();
});
Given(/^I am on the home page$/, async () => {
await page.navigateTo();
});
When(/^I do nothing$/, () => {});
Then(/^I should see the title$/, async () => {
expect(await page.getTitleText()).to.equal('Welcome to angular-cli-cucumber-demo!');
});
Lastly, here is a snippet from my page objects file:
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getTitleText() {
return element(by.css('app-root h1')).getText();
}
}
Upon attempting to run the tests using the command ng e2e
, I encountered the following error:
DevTools listening on ws://127.0.0.1:56273/devtools/browser/7653bd59-c490-4ac0-a00e-0d3132dc5b11
[0417/123615.432:ERROR:broker_win.cc(137)] Error sending sync broker message: Error (0x5) while retrieving error. (0xE8)
[0417/123615.433:ERROR:command_buffer_proxy_impl.cc(92)] ContextResult::kFatalFailure: AllocateAndMapSharedMemory failed
[12:36:17] E/launcher - Error: C:\Users\A527629\Documents\workspace-vs-code\poc-serenity\e2e\src\steps\app.steps.ts:1
(function (exports, require, module, __filename, __dirname) { import { AppPage } from '../pages/app.po';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at supportCodePaths.forEach.codePath (C:\Users\A527629\Documents\workspace-vs-code\poc-serenity\node_modules\cucumber\lib\cli\index.js:142:42)
at Array.forEach (<anonymous>)
at Cli.getSupportCodeLibrary (C:\Users\A527629\Documents\workspace-vs-code\poc-serenity\node_modules\cucumber\lib\cli\index.js:142:22)
at C:\Users\A527629\Documents\workspace-vs-code\poc-serenity\node_modules\cucumber\lib\cli\index.js:169:41
at Generator.next (<anonymous>)
at asyncGeneratorStep (C:\Users\A527629\Documents\workspace-vs-code\poc-serenity\node_modules\cucumber\lib\cli\index.js:44:103)
[12:36:17] E/launcher - Process exited with error code 100
An unexpected error occurred: undefined