This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from technologiestiftung/test/STADTPULS-622-a…
…dd-cypress-testing test(STADTPULS-622): add basic Cypress testing
- Loading branch information
Showing
15 changed files
with
35,419 additions
and
923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,78 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
es6: true, | ||
jest: true, | ||
}, | ||
parserOptions: { ecmaVersion: 8, project: './tsconfig.json', tsconfigRootDir: './' }, // to enable features such as async/await | ||
ignorePatterns: ['node_modules/*', '.next/*', '.out/*', '!.prettierrc.js'], // We don't want to lint generated files nor node_modules, but we want to lint .prettierrc.js (ignored by default by eslint) | ||
extends: ['eslint:recommended'], | ||
overrides: [ | ||
// This configuration will apply only to TypeScript files | ||
{ | ||
plugins: ['@typescript-eslint', 'import'], | ||
files: ['**/*.ts', '**/*.tsx', '**/*.mdx'], | ||
parser: '@typescript-eslint/parser', | ||
settings: { | ||
react: { version: 'detect' }, | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts', '.tsx'], | ||
}, | ||
'import/resolver': { | ||
typescript: { | ||
alwaysTryTypes: true, | ||
}, | ||
}, | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
es6: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', // TypeScript rules | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
'plugin:react/recommended', // React rules | ||
'plugin:react-hooks/recommended', // React hooks rules | ||
'plugin:jsx-a11y/recommended', // Accessibility rules | ||
'plugin:prettier/recommended', // Prettier recommended rules | ||
], | ||
rules: { | ||
// We will use TypeScript's types for component props instead | ||
'react/prop-types': 'off', | ||
root: true, | ||
env: { | ||
node: true, | ||
es6: true, | ||
jest: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 8, | ||
project: "./tsconfig.json", | ||
tsconfigRootDir: "./", | ||
}, // to enable features such as async/await | ||
ignorePatterns: [ | ||
"node_modules/*", | ||
".next/*", | ||
".out/*", | ||
"!.prettierrc.js", | ||
"cypress/*", | ||
], // We don't want to lint generated files nor node_modules, but we want to lint .prettierrc.js (ignored by default by eslint) | ||
extends: ["eslint:recommended"], | ||
overrides: [ | ||
// This configuration will apply only to TypeScript files | ||
{ | ||
plugins: ["@typescript-eslint", "import"], | ||
files: ["**/*.ts", "**/*.tsx", "**/*.mdx"], | ||
parser: "@typescript-eslint/parser", | ||
settings: { | ||
react: { version: "detect" }, | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"], | ||
}, | ||
"import/resolver": { | ||
typescript: { | ||
alwaysTryTypes: true, | ||
}, | ||
}, | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
es6: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", // TypeScript rules | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:react/recommended", // React rules | ||
"plugin:react-hooks/recommended", // React hooks rules | ||
"plugin:jsx-a11y/recommended", // Accessibility rules | ||
"plugin:prettier/recommended", // Prettier recommended rules | ||
], | ||
rules: { | ||
// We will use TypeScript's types for component props instead | ||
"react/prop-types": "off", | ||
|
||
// No need to import React when using Next.js | ||
'react/react-in-jsx-scope': 'off', | ||
// No need to import React when using Next.js | ||
"react/react-in-jsx-scope": "off", | ||
|
||
// This rule is not compatible with Next.js's <Link /> components | ||
'jsx-a11y/anchor-is-valid': 'off', | ||
// This rule is not compatible with Next.js's <Link /> components | ||
"jsx-a11y/anchor-is-valid": "off", | ||
|
||
// Why would you want unused vars? | ||
'@typescript-eslint/no-unused-vars': ['error'], | ||
// Why would you want unused vars? | ||
"@typescript-eslint/no-unused-vars": ["error"], | ||
|
||
// I suggest this setting for requiring return types on functions only where useful | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'warn', | ||
{ | ||
allowExpressions: true, | ||
allowConciseArrowFunctionExpressionsStartingWithVoid: true, | ||
}, | ||
], | ||
'prettier/prettier': ['error', {}, { usePrettierrc: true }], // Includes .prettierrc.js rules | ||
'import/no-unresolved': 'error', | ||
}, | ||
}, | ||
], | ||
} | ||
// I suggest this setting for requiring return types on functions only where useful | ||
"@typescript-eslint/explicit-function-return-type": [ | ||
"warn", | ||
{ | ||
allowExpressions: true, | ||
allowConciseArrowFunctionExpressionsStartingWithVoid: true, | ||
}, | ||
], | ||
"prettier/prettier": ["error", {}, { usePrettierrc: true }], // Includes .prettierrc.js rules | ||
"import/no-unresolved": "error", | ||
}, | ||
}, | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Test and Build | ||
|
||
on: | ||
push: | ||
branches: [main, staging] | ||
pull_request: | ||
branches: [main, staging] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: remote-development | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Read .nvmrc | ||
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" | ||
id: nvm | ||
- name: Use Node.js (.nvmrc) | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ steps.nvm.outputs.NVMRC }} | ||
- name: Set timezone | ||
uses: szenius/set-timezone@v1.0 | ||
with: | ||
timezoneLinux: "Europe/Berlin" | ||
- run: npm ci | ||
- run: npm run lint | ||
- run: npm run type-check | ||
- run: npm run test:ci | ||
env: | ||
CI: true | ||
- name: Cypress run | ||
uses: cypress-io/github-action@v2 | ||
with: | ||
build: npm run build | ||
start: npm start -- -p 3333 | ||
env: | ||
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} | ||
NEXT_PUBLIC_SUPABASE_PUBLIC_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_PUBLIC_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"baseUrl": "http://localhost:3333", | ||
"testFiles": "**/*.test.*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": [ | ||
"plugin:cypress/recommended" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe("The Accounts page", () => { | ||
it("successfully loads", () => { | ||
cy.visit("/accounts"); | ||
|
||
cy.findByRole("heading", { name: /Alle Accounts/i }).should("exist"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
describe("The Docs page", () => { | ||
it("successfully loads", () => { | ||
cy.visit("/docs"); | ||
|
||
cy.findByRole("heading", { name: /Willkommen bei Stadtpuls/i }).should( | ||
"exist" | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe("The Home Page", () => { | ||
it("successfully loads", () => { | ||
cy.visit("/"); | ||
|
||
cy.findByRole("link", { name: /Sensoren ansehen/i }).should("exist"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe("The Sensors page", () => { | ||
it("successfully loads", () => { | ||
cy.visit("/sensors"); | ||
|
||
cy.findByRole("heading", { name: /Alle Sensoren/i }).should("exist"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@testing-library/cypress/add-commands"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./commands"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress", "@testing-library/cypress"] | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
module.exports = { | ||
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'], | ||
moduleNameMapper: { | ||
'^@components(.*)$': '<rootDir>/src/components$1', | ||
'^@lib(.*)$': '<rootDir>/src/lib$1', | ||
'^@common(.*)$': '<rootDir>/src/common$1', | ||
'^@mocks(.*)$': '<rootDir>/src/mocks$1', | ||
'^@auth(.*)$': '<rootDir>/src/auth$1', | ||
'\\.css$': '<rootDir>/src/mocks/cssMock.ts', | ||
'\\/mocks/index$': '<rootDir>/src/mocks/mswMock.ts', | ||
} | ||
} | ||
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"], | ||
moduleNameMapper: { | ||
"^@components(.*)$": "<rootDir>/src/components$1", | ||
"^@lib(.*)$": "<rootDir>/src/lib$1", | ||
"^@common(.*)$": "<rootDir>/src/common$1", | ||
"^@mocks(.*)$": "<rootDir>/src/mocks$1", | ||
"^@auth(.*)$": "<rootDir>/src/auth$1", | ||
"\\.css$": "<rootDir>/src/mocks/cssMock.ts", | ||
"\\/mocks/index$": "<rootDir>/src/mocks/mswMock.ts", | ||
}, | ||
modulePathIgnorePatterns: ["<rootDir>/cypress/"], | ||
}; |
Oops, something went wrong.