github-action
github-action copied to clipboard
Cypress Action doesn't pick proper configuration from `with:` and `cypress.config.ts`
Hi, I recently wanted to integrate Cypress + Dashboard into my app.
I have some issues with sending Cypress runs to the Dashboard from a GitHub Action.
It looks like the action doesn't recognize any configuration both from main.yml and cypress.config.ts.
Please forgive my ignorance but to me, it looks more like an issue because after spending a few hours reading various documentations, examples projects and official Cypress videos, I still can't get it running properly.
Here is an extract of the GitHub Action log:
[checkout, npm install, etc.]
/usr/local/bin/npx cypress cache list
┌─────────┬───────────────────┐
│ version │ last used │
├─────────┼───────────────────┤
│ 10.2.0 │ a few seconds ago │
└─────────┴───────────────────┘
build app command "npm run build -- --sourcemap false"
current working directory "/home/runner/work/react-frontend/react-frontend"
/usr/local/bin/npm run build -- --sourcemap false
> [email protected] build
> tsc && vite build "--sourcemap" "false"
vite v2.9.13 building for production...
[...]
start server "npm run preview command "npm run preview"
current working directory "/home/runner/work/react-frontend/react-frontend"
waiting on "http://localhost:3001" with timeout of 60 seconds
/usr/local/bin/npm run preview
> [email protected] preview
> vite preview --port 3001
> Local: http://localhost:3001/
> Network: use `--host` to expose
Using custom test command: npm run test:e2e:ci
run tests command "npm run test:e2e:ci"
current working directory "/home/runner/work/react-frontend/react-frontend"
/usr/local/bin/npm run test:e2e:ci
> [email protected] test:e2e:ci
> cypress run --e2e
[2221:0630/093805.5512[36](https://github.com/deniseaudio/react-frontend/runs/7128739556?check_suite_focus=true#step:3:37):ERROR:sandbox_linux.cc([37](https://github.com/deniseaudio/react-frontend/runs/7128739556?check_suite_focus=true#step:3:38)7)] InitializeSandbox() called with multiple threads in process gpu-process.
[2221:0630/09[38](https://github.com/deniseaudio/react-frontend/runs/7128739556?check_suite_focus=true#step:3:39)05.555801:ERROR:gpu_memory_buffer_support_x11.cc([44](https://github.com/deniseaudio/react-frontend/runs/7128739556?check_suite_focus=true#step:3:45))] dri3 extension not supported.
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
This project has been configured to record runs on our Dashboard.
# Why it hasn't found my project ID? It is defined in my Cypress config.
It currently has the projectId: ***
# It has found my recovery key defined as a GitHub Action env. var, but hasn't detected the `record: true` parameter in my Action configuration.
You also provided your Record Key, but you did not pass the --record flag.
This run will not be recorded.
If you meant to have this run recorded please additionally pass this flag:
$cypress run --record
If you don't want to record these runs, you can silence this warning:
$cypress run --record false
https://on.cypress.io/recording-project-runs
# After that, Cypress runs as it should, but doesn't send my report.
Here is the entirety of the my Cypress configuration file:
// cypress.config.ts
import { defineConfig } from "cypress";
export default defineConfig({
projectId: "7n337z",
component: {
devServer: {
framework: "react",
bundler: "vite",
},
},
e2e: {
baseUrl: "http://localhost:3001",
},
viewportHeight: 768,
viewportWidth: 1366,
});
Here is a relevant extract of my package.json:
// package.json
{
"scripts": {
"build": "tsc && vite build",
"preview": "vite preview --port 3001",
"test:e2e": "cypress run --e2e",
"test:e2e:ci": "cypress run --e2e"
}
}
Here is the the entirety of my single GitHub workflow configuration:
# .github/workflows/main.yml
name: Build and run Cypress tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-20.04
steps:
- name: Checkout code from repository
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly and run all Cypress tests
- name: Run Cypress E2E tests
uses: cypress-io/github-action@v4
with:
# Records the run for Cypress Dashboard
record: true
# Build app
build: npm run build -- --sourcemap false
# Run web-server from build dist/ output
start: npm run preview
# Wait for web-server before starting tests
wait-on: 'http://localhost:3001'
# Custom command to start Cypress tests
command: npm run test:e2e:ci
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
# Pass GitHub token generated automatically by the action itself
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print result
run: |
echo Cypress finished with: ${{ steps.cypress.outcome }}
echo See results at ${{ steps.cypress.outputs.dashboardUrl }}