我有一个 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);
}
}
我有以下结构
我想要做的是导入 TestUtilsimport { 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
但仍然出现此错误。