Within my cypress plugin file located at
frontend/cypress/plugins/index.ts
, I have the following code snippet:
export default ((on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}) as Cypress.PluginConfig
Interestingly, when I execute this on my local machine, everything works seamlessly. However, the moment I integrate cypress-io/github-action@v2
within my GitHub actions flow, I encounter 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'
Provided below is the content of 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'
Moreover, my frontend/cypress.json
configuration file remains unpopulated, while the frontend/cypress/tsconfig.json
within the cypress directory contains the following values:
{
"include": [
"./integration/**/*",
"./support/**/*"
],
"compilerOptions": {
"isolatedModules": false,
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress"
]
}
}
Furthermore, the
frontend/cypress/plugins/tsconfig.json
file is housed within the Plugins folder and incorporates the following configurations:
{
"include": [
"./**/*"
],
"compilerOptions": {
"module": "CommonJS",
"preserveValueImports": false,
"types": [
"node",
"cypress/types/cypress"
]
}
}
I have essentially mirrored these settings from npm init vue@latest
with typescript and cypress. Despite this, I am encountering an issue. What could be the root cause?