简体   繁体   中英

Protractor e2e tests not running when using --spec

I'm running 'ng e2e' on an Angular CLI project but I wanted to specify the test to run instead of running them all.
When I use ' ng e2e --aot ' the test will run fine.
But when I use ' ng e2e --aot --spec=./e2e/checkout.e2e-spec.ts ' I will get the error message:

[18:24:51] E/configParser - Error code: 105
[18:24:51] E/configParser - Error message: failed loading configuration file .\e2e\checkout.e2e-spec.ts
[18:24:51] E/configParser - C:\GitRepos\checkout-ui\e2e\checkout.e2e-spec.ts:1
(function (exports, require, module, __filename, __dirname) { import { CheckOut } from './checkoutPage.po';
                                                              ^^^^^^
SyntaxError: Unexpected token import

So the test will fail when I use --spec to specify the test... and i've no idea why :(
Any ideas are greatly appreciated

Below are my test spec and my po if it helps.
Many Thanks.

Test Spec

import { CheckOut } from './checkoutPage.po';

describe('When I arrive at the checkout', () => {
  let page: CheckOut;

  beforeEach(() => {
    page = new CheckOut();
  });

  it('the checkout button should be clicked', () => {
    page.navigateToCheckout();
    page.clickbutton();
  });
});

PO

import { browser, element, by } from 'protractor';

export class CheckOut {
  shippingElement = element(by.tagName('shipping'));
  shippingSaveAndCoutinueButton = this.shippingElement.element(by.tagName('button'));

  navigateToCheckout() {
    browser.get(
      'http:/mycompany.net/e13cc528-b048-49e6-8981-c59755a6690a',
    );
  }

  clickbutton() {
    this.shippingSaveAndCoutinueButton.click();
  }
}

Your issue is nothing with your spec and P. You use wrong cmd option: spec , it should be specs

在此处输入图片说明

More detail at here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM