我有以下用于 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
當我在我的機器上運行它時它正在作業,但是當我cypress-io/github-action@v2在我的 github 操作中使用它時,我收到以下錯誤:
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組態檔是空的。這是我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"
]
}
}
npm init vue@latest我已經使用 typescript 和 cypress復制了這個配置。
有什么問題?
uj5u.com熱心網友回復:
我忘記將打字稿添加到我的依賴項中:
npm install typescript --save-dev
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/481720.html
標籤:javascript 打字稿 测试 柏 e2e-测试
