Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract login from Cypress tests #981

Merged
merged 13 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:

- name: Run Cypress tests
uses: cypress-io/github-action@v6
env:
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
AUTH0_USERNAME: ${{ secrets.AUTH0_USERNAME }}
AUTH0_PASSWORD: ${{ secrets.AUTH0_PASSWORD }}
with:
command: yarn test:e2e:ci

- name: Upload screenshots
uses: actions/upload-artifact@v4
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ eslint-results.sarif
cypress/videos
*.DS_Store

# Env
.env
.env.test

# VS Code
.vscode
19 changes: 17 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
/* eslint-disable @typescript-eslint/no-namespace */
import { defineConfig } from 'cypress'

declare global {
namespace NodeJS {
interface ProcessEnv {
AUTH0_DOMAIN: string
AUTH0_USERNAME: string
AUTH0_PASSWORD: string
}
}
}

const config = defineConfig({
projectId: 'brkojt',
e2e: {
env: {
AUTH0_DOMAIN: process.env.AUTH0_DOMAIN,
AUTH0_USERNAME: process.env.AUTH0_USERNAME,
AUTH0_PASSWORD: process.env.AUTH0_PASSWORD
},
setupNodeEvents() { },
// Path to e2e specs folder
specPattern: './test/cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
// Path to the fake data
fixturesFolder: './test/fake_data',
supportFolder: './test/cypress/support',
supportFile: './test/cypress/support/e2e.js',
supportFile: './test/cypress/support/e2e.ts',
baseUrl: 'http://localhost:3000',
testIsolation: false,
experimentalRunAllSpecs: true,
Expand Down
34 changes: 7 additions & 27 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import globals from 'globals'
import eslintJsPlugin from '@eslint/js'
import tseslint from 'typescript-eslint'
import stylistic from '@stylistic/eslint-plugin'
import pluginCypress from 'eslint-plugin-cypress'
import pluginCypress from 'eslint-plugin-cypress/flat'
import pluginVue from 'eslint-plugin-vue'
import withNuxt from './.nuxt/eslint.config.mjs'

Expand All @@ -14,8 +14,8 @@ export default withNuxt(
'.output/*',
'.nuxt/*',
'coverage/*',
'cypress/*',
'.yarn/*',
'test/vitest',
'typedefs/gqlTypes.ts'
]
},
Expand All @@ -36,7 +36,7 @@ export default withNuxt(
'@typescript-eslint': tseslint.plugin,
'@stylistic': stylistic
},
ignores: ['./typeDefs/gqlTypes.ts', './typesgeneratorconfig.ts', 'cypress/**/*'],
ignores: ['./typeDefs/gqlTypes.ts', './typesgeneratorconfig.ts'],
rules: {
...tseslint.configs.recommended,
// TS specific rules
Expand Down Expand Up @@ -94,32 +94,12 @@ export default withNuxt(
'vue/html-indent': ['error', 4]
}
},
// Linting for tests (cypress + pinia)
// Linting for Cypress (https://www.npmjs.com/package/eslint-plugin-cypress)
ermish marked this conversation as resolved.
Show resolved Hide resolved
{
languageOptions: {
globals: {
cy: true,
it: true,
describe: true,
context: true,
beforeEach: true,
before: true
}
},
files: ['cypress/e2e/*.ts', 'test/**/*'],
plugins: {
cypress: pluginCypress
},
files: ['test/cypress/**/*'],
...pluginCypress.configs.recommended,
ermish marked this conversation as resolved.
Show resolved Hide resolved
rules: {
//this is to support chai chaining syntax
'@typescript-eslint/no-unused-expressions': 'off'
// 'cypress/no-assigning-return-values": "error",
// "cypress/no-unnecessary-waiting": "error",
// "cypress/assertion-before-screenshot": "warn",
// "cypress/no-force": "warn",
// "cypress/no-async-tests": "error",
// "cypress/no-async-before": "error",
// "cypress/no-pause": "error"
'cypress/no-unnecessary-waiting': 'off'
}
}
)
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"test": "yarn test:pinia --run && yarn test:e2e",
"test:pinia": "nuxi prepare && nuxi generate && vitest",
"test:pinia:coverage": "vitest run --coverage",
"test:e2e": "cypress run --e2e --browser chrome --record --key 04a1fe54-0011-407b-b7d7-fcb9b2daf1e6"
"test:e2e": "dotenv -e .env.test -o -- cypress open",
"test:e2e:ci": "dotenv -e .env.test -o -- cypress run --e2e"
},
"packageManager": "[email protected]",
"engines": {
Expand Down Expand Up @@ -59,6 +60,7 @@
"autoprefixer": "^10.4.20",
"cypress": "^13.13.2",
"cypress-plugin-tab": "^1.0.5",
"dotenv-cli": "^8.0.0",
"eslint": "^9.8.0",
"eslint-plugin-cypress": "^3.4.0",
"eslint-plugin-json": "^4.0.1",
Expand Down
Loading