Cypress is not running in ci SyntaxError: Unexpected token 'export' with cypress-io/github-action@v2 typescript

Cypress is not running in ci SyntaxError: Unexpected token 'export' with cypress-io/github-action@v2 typescript

我有以下用于 cypress 的插件文件: frontend/cypress/plugins/index.ts:

export default ((on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
}) as Cypress.PluginConfig

当我在我的机器上 运行 它工作时,但当我在我的 github 操作中使用 cypress-io/github-action@v2 时,我收到以下错误:

Your pluginsFile is invalid: /home/runner/work/XX/XX/frontend/cypress/plugins/index.ts

It threw an error when required, check the stack trace below:

/home/runner/work/XX/XX/frontend/cypress/plugins/index.ts:14
export default ((on, config) => {
^^^^^^
SyntaxError: Unexpected token 'export'

这是我的 .github/workflows/cypress-tests.yml:

name: Cypress Tests

jobs:
  cypress-run:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
    
      - name: Install dependencies
        run: | 
          cd frontend  
          npm ci
                
      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          working-directory: frontend
          start: npm run serve
          wait-on: 'http://localhost:8080'  

我的 frontend/cypress.json 配置文件是空的。 这是我在 cypress 文件夹中的 frontend/cypress/tsconfig.json

{
    "include": [
        "./integration/**/*",
        "./support/**/*"
    ],
    "compilerOptions": {
        "isolatedModules": false,
        "target": "es5",
        "lib": [
            "es5",
            "dom"
        ],
        "types": [
            "cypress"
        ]
    }
}

这个 frontend/cypress/plugins/tsconfig.json 在插件文件夹中:

{
    "include": [
        "./**/*"
    ],
    "compilerOptions": {
        "module": "CommonJS",
        "preserveValueImports": false,
        "types": [
            "node",
            "cypress/types/cypress"
        ]
    }
}

我用 typescript 和 cypress 从 npm init vue@latest 复制了这个配置。

有什么问题?

我忘了将打字稿添加到我的依赖项中:

npm install typescript --save-dev