我有一个Util类,其中保存了一些有关测试类的信息
import * as electron from "electron";
import { Application } from "spectron";
export class TestUtils {
public app: Application;
public windowsCount = 2;
public windowByIndex() { return this.windowsCount - 1; }
public setUp() {
// start application
this.app = new Application({
// path to electron app
args: ["./dist/main.js"],
path: "" + electron,
startTimeout: 30000,
waitTimeout: 30000,
});
return this.app.start();
}
public tearDown() {
// close browser
const windows = this.app.client.windowHandles() as any;
this.app.client.close(windows.sessionId);
}
}
我有以下结构
我想做的是用import { TestUtils } from "../helpers/TestUtils"
但是我得到了错误
import { TestUtils } from "../helpers/TestUtils"
^^^^^^
SyntaxError: Unexpected token import
我的tsconfig.ts文件包含
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es2017"
],
"noImplicitAny": false,
"skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"]
}
},
"include": [
"src/**/*"
]
}
我已将app.e2e-spec.js
更改为app.e2e-spec.ts
,但仍然出现此错误。