diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cb90323..0247b1c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,6 +58,7 @@ test-and-build-frontend: - npm run test:ci - npm run build - npm run openapi-clients:replace-base-path-for-prod + coverage: /^Statements\s*:\s*([^%]+)/ artifacts: paths: - frontend/dist @@ -76,8 +77,9 @@ e2e-test: - sleep 30 - cd ../e2e - npm ci - - npm run cypress + - npm run cypress:ci - npm run coverage:ci + coverage: /^Statements\s*:\s*([^%]+)/ artifacts: when: always expire_in: 1 hour diff --git a/e2e/cypress.config.ci.js b/e2e/cypress.config.ci.js new file mode 100644 index 0000000..c8d3bc5 --- /dev/null +++ b/e2e/cypress.config.ci.js @@ -0,0 +1,21 @@ +const { defineConfig } = require('cypress'); + +module.exports = defineConfig({ + reporter: 'cypress-multi-reporters', + reporterOptions: { + configFile: 'cypress/reporter-config.json', + }, + watchForFileChanges: false, + viewportWidth: 1920, + viewportHeight: 1080, + e2e: { + specPattern: 'instrumented/e2e/**/*.cy.{js,jsx,ts,tsx}', + // We've imported your old cypress plugins here. + // You may want to clean this up later by importing these. + setupNodeEvents(on, config) { + require('@cypress/code-coverage/task')(on, config); + return config; + }, + baseUrl: 'http://localhost:4200/', + }, +}); diff --git a/e2e/cypress.config.js b/e2e/cypress.config.js index d1f7ede..e6df400 100644 --- a/e2e/cypress.config.js +++ b/e2e/cypress.config.js @@ -13,7 +13,6 @@ module.exports = defineConfig({ // You may want to clean this up later by importing these. setupNodeEvents(on, config) { require('@cypress/code-coverage/task')(on, config); - require('./cypress/plugins/index.js')(on, config); return config; }, baseUrl: 'http://localhost:4200/', diff --git a/e2e/cypress/plugins/index.js b/e2e/cypress/plugins/index.js deleted file mode 100644 index 8229063..0000000 --- a/e2e/cypress/plugins/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) - -/** - * @type {Cypress.PluginConfig} - */ -// eslint-disable-next-line no-unused-vars -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -}; diff --git a/e2e/package.json b/e2e/package.json index 9d05bdb..9049f3a 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -19,10 +19,11 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "cypress": "cypress run", + "cypress:ci": "nyc instrument --compact=false cypress instrumented && cypress run --config-file cypress.config.ci.js", "cypress:open": "cypress open", "prettier:check": "prettier --check '**/*.{json,html,scss,ts,js}'", "prettier:fix": "prettier --write '**/*.{json,html,scss,ts,js}'", - "coverage:ci": "nyc report --reporter=text-summary -t coverage --report-dir coverage/summary" + "coverage:ci": "nyc report --reporter=text-summary" }, "author": "Heimo Stranner", "license": "ISC"