[英]Cypress is not running in ci SyntaxError: Unexpected token 'export' with cypress-io/github-action@v2 typescript
I have the following plugin file for cypress: frontend/cypress/plugins/index.ts
:我有以下用于赛普拉斯的插件文件:
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
When I run it on my machine it's working but when I use cypress-io/github-action@v2
in my github actions I get the following error:当我在我的机器上运行它时它正在工作,但是当我在我的 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'
This is my .github/workflows/cypress-tests.yml
:这是我的
.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'
My frontend/cypress.json
config file is empty.我的
frontend/cypress.json
配置文件是空的。 This is my frontend/cypress/tsconfig.json
in the cypress folder:这是我在 cypress 文件夹中的
frontend/cypress/tsconfig.json
:
{
"include": [
"./integration/**/*",
"./support/**/*"
],
"compilerOptions": {
"isolatedModules": false,
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress"
]
}
}
This frontend/cypress/plugins/tsconfig.json
is inside the Plugins folder:这个
frontend/cypress/plugins/tsconfig.json
位于 Plugins 文件夹中:
{
"include": [
"./**/*"
],
"compilerOptions": {
"module": "CommonJS",
"preserveValueImports": false,
"types": [
"node",
"cypress/types/cypress"
]
}
}
I have copied this configuration from npm init vue@latest
with typescript and cypress.我已经使用 typescript 和 cypress 从
npm init vue@latest
复制了这个配置。
What's the problem?有什么问题?
我忘记将打字稿添加到我的依赖项中:
npm install typescript --save-dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.