I have the following plugin file for cypress:
frontend/cypress/plugins/index.ts
:
JavaScript
x
5
1
export default ((on, config) => {
2
// `on` is used to hook into various events Cypress emits
3
// `config` is the resolved Cypress config
4
}) as Cypress.PluginConfig
5
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:
JavaScript
1
9
1
Your pluginsFile is invalid: /home/runner/work/XX/XX/frontend/cypress/plugins/index.ts
2
3
It threw an error when required, check the stack trace below:
4
5
/home/runner/work/XX/XX/frontend/cypress/plugins/index.ts:14
6
export default ((on, config) => {
7
^^^^^^
8
SyntaxError: Unexpected token 'export'
9
This is my .github/workflows/cypress-tests.yml
:
JavaScript
1
21
21
1
name: Cypress Tests
2
3
jobs:
4
cypress-run:
5
runs-on: ubuntu-20.04
6
steps:
7
- name: Checkout repository
8
uses: actions/checkout@v2
9
10
- name: Install dependencies
11
run: |
12
cd frontend
13
npm ci
14
15
- name: Cypress run
16
uses: cypress-io/github-action@v2
17
with:
18
working-directory: frontend
19
start: npm run serve
20
wait-on: 'http://localhost:8080'
21
My frontend/cypress.json
config file is empty.
This is my frontend/cypress/tsconfig.json
in the cypress folder:
JavaScript
1
18
18
1
{
2
"include": [
3
"./integration/**/*",
4
"./support/**/*"
5
],
6
"compilerOptions": {
7
"isolatedModules": false,
8
"target": "es5",
9
"lib": [
10
"es5",
11
"dom"
12
],
13
"types": [
14
"cypress"
15
]
16
}
17
}
18
This frontend/cypress/plugins/tsconfig.json
is inside the Plugins folder:
JavaScript
1
14
14
1
{
2
"include": [
3
"./**/*"
4
],
5
"compilerOptions": {
6
"module": "CommonJS",
7
"preserveValueImports": false,
8
"types": [
9
"node",
10
"cypress/types/cypress"
11
]
12
}
13
}
14
I have copied this configuration from npm init vue@latest
with typescript and cypress.
What’s the problem?
Advertisement
Answer
I forgot to add typescript to my dependencies:
JavaScript
1
2
1
npm install typescript --save-dev
2