1

テストクラスの情報を保存した 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);
  }
}

そして私は次の構造を持っています

ここに画像の説明を入力

私がやろうとしているのは、TestUtils をインポートすることです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が、まだこのエラーが発生します。

4

0 に答える 0