Cypress在CI Syntaxerror中没有运行:出乎意料的令牌' Export'使用Cypress-io/github-action@v2打字稿
我有以下柏树的插件文件: 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'
我的front> frontend/cypress.json.json
配置文件是空的。 这是我的frontend/cypress/tsconfig.json
在柏树文件夹中:
{
"include": [
"./integration/**/*",
"./support/**/*"
],
"compilerOptions": {
"isolatedModules": false,
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress"
]
}
}
this frontend/cypress/plugins/tsconfig.json
在插件文件夹中:
{
"include": [
"./**/*"
],
"compilerOptions": {
"module": "CommonJS",
"preserveValueImports": false,
"types": [
"node",
"cypress/types/cypress"
]
}
}
我已经复制了此配置来自npm init vue@最新
带有打字稿和柏树。
有什么问题?
I have the following plugin file for 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
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:
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
:
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.
This is my frontend/cypress/tsconfig.json
in the cypress folder:
{
"include": [
"./integration/**/*",
"./support/**/*"
],
"compilerOptions": {
"isolatedModules": false,
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress"
]
}
}
This frontend/cypress/plugins/tsconfig.json
is inside the Plugins folder:
{
"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.
What's the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我忘了将打字稿添加到我的依赖项中:
I forgot to add typescript to my dependencies: