Skip to content

Commit

Permalink
Make cypress run again and exclude some files from coverage #1379
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Mar 15, 2024
1 parent 8608169 commit ec83e56
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 51 deletions.
9 changes: 2 additions & 7 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'cypress'
import { defineConfig } from 'cypress';

export default defineConfig({
chromeWebSecurity: false,
Expand All @@ -8,11 +8,6 @@ export default defineConfig({
openMode: 0,
},
e2e: {
setupNodeEvents(on, config) {
on('task', {
failed: require('cypress-failed-log/src/failed')(),
})
},
baseUrl: 'http://127.0.0.1:3000',
},
})
});
2 changes: 0 additions & 2 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')

require('cypress-failed-log');
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"connected-react-router": "6.9.3",
"cookie-parser": "1.4.5",
"custom-event-polyfill": "1.0.7",
"cypress-failed-log": "2.10.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "2.15.1",
"eslint-plugin-prettier": "5.1.3",
Expand Down Expand Up @@ -67,7 +66,7 @@
"lint:cypress": "eslint --ext=tsx --ext=js --ext=jsx --fix ./cypress",
"serve:plugins": "node micro-frontend-tools/serve-plugins.js",
"start": "cross-env concurrently \"yarn serve:plugins\" \"node server/auth-server.js\" \"react-scripts start\"",
"build:e2e": "cross-env GENERATE_SOURCEMAP=false react-scripts build",
"build:e2e": "cross-env GENERATE_SOURCEMAP=false yarn build",
"test": "vitest --coverage",
"test:watch": "react-scripts test --env=jsdom --watch",
"e2e:serve": "yarn build:e2e && concurrently \"node server/auth-server.js e2e\" \"node ./server/e2e-test-server.js\"",
Expand Down Expand Up @@ -138,4 +137,4 @@
"wait-on": "7.2.0"
},
"packageManager": "[email protected]"
}
}
26 changes: 14 additions & 12 deletions server/e2e-test-server.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');
var axios = require('axios');
import express from 'express';
import path from 'path';
import serveStatic from 'serve-static';
import axios from 'axios';

var app = express();

app.get('/settings.json', function(req, res) {
res.sendFile(path.join(__dirname, 'e2e-settings.json'));
app.get('/settings.json', function (req, res) {
res.sendFile(path.resolve('./server/e2e-settings.json'));
});

app.get('/plugins/*', function(req, res) {
res.sendFile(path.join(__dirname, req.originalUrl.replace('/plugins/', '')));
app.get('/plugins/*', function (req, res) {
res.sendFile(
path.resolve(`./server/${req.originalUrl.replace('/plugins/', '')}`)
);
});

app.use(
express.json(),
serveStatic(path.resolve('./build'), { index: ['index.html', 'index.htm'] })
serveStatic(path.resolve('./dist'), { index: ['index.html', 'index.htm'] })
);

app.post('/api/*', function(req, res) {
app.post('/api/*', function (req, res) {
axios
.post('http://127.0.0.1:8000' + req.url, req.body)
.then(apiRes => {
Expand All @@ -29,8 +31,8 @@ app.post('/api/*', function(req, res) {
});
});

app.get('/*', function(req, res) {
res.sendFile(path.resolve('./build/index.html'));
app.get('/*', function (req, res) {
res.sendFile(path.resolve('./dist/index.html'));
});

app.listen(3000);
10 changes: 4 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ export default defineConfig(({ command, mode }) => {
exclude: [
'public/*',
'server/*',
// Leave handlers to show up unused code
// 'src/mocks/browser.ts',
// 'src/mocks/server.ts',
// 'src/vite-env.d.ts',
// 'src/main.tsx',
// 'src/testUtils.tsx',
'__mocks__/axios.ts',
'micro-frontend-tools/serve-plugins.js',
'.eslintrc.cjs',
'src/main.tsx',
],
},
},
Expand Down
22 changes: 1 addition & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4324,7 +4324,7 @@ __metadata:
languageName: node
linkType: hard

"chalk@npm:^2.3.0, chalk@npm:^2.4.2":
"chalk@npm:^2.4.2":
version: 2.4.2
resolution: "chalk@npm:2.4.2"
dependencies:
Expand Down Expand Up @@ -4835,16 +4835,6 @@ __metadata:
languageName: node
linkType: hard

"cypress-failed-log@npm:2.10.0":
version: 2.10.0
resolution: "cypress-failed-log@npm:2.10.0"
dependencies:
debug: "npm:4.3.4"
logdown: "npm:3.3.1"
checksum: 10/5321f401175d53a3c1ef8751b9e4c635f74e2f8a8461034469950d14cb7ccdaca5231ed6cd88c78341786e3bf2e938d107ed9f7443a656e9c407d761228c699b
languageName: node
linkType: hard

"cypress@npm:13.6.4":
version: 13.6.4
resolution: "cypress@npm:13.6.4"
Expand Down Expand Up @@ -7842,15 +7832,6 @@ __metadata:
languageName: node
linkType: hard

"logdown@npm:3.3.1":
version: 3.3.1
resolution: "logdown@npm:3.3.1"
dependencies:
chalk: "npm:^2.3.0"
checksum: 10/2139caa178bd43ff8050df43e9aacb6cbc79815f07f2388a6715e3ea2b72078526671bbc44919e3bb2aba78c95c70f9afa7faa2f0bea148fb865943c114687f9
languageName: node
linkType: hard

"loglevel@npm:1.9.1":
version: 1.9.1
resolution: "loglevel@npm:1.9.1"
Expand Down Expand Up @@ -9734,7 +9715,6 @@ __metadata:
cross-env: "npm:7.0.3"
custom-event-polyfill: "npm:1.0.7"
cypress: "npm:13.6.4"
cypress-failed-log: "npm:2.10.0"
eslint: "npm:8.56.0"
eslint-config-prettier: "npm:9.1.0"
eslint-config-react-app: "npm:7.0.0"
Expand Down

0 comments on commit ec83e56

Please sign in to comment.