forked from opencollective/opencollective-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
68 lines (62 loc) · 2.21 KB
/
cypress.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// eslint-disable-next-line n/no-unpublished-require
const { defineConfig } = require('cypress');
const fs = require('fs');
const { getTextFromPdfContent } = require('./test/cypress/scripts/get-text-from-pdf-content.ts');
module.exports = defineConfig({
experimentalMemoryManagement: true,
viewportWidth: 1200,
viewportHeight: 1660,
projectId: 'yt5kwm',
defaultCommandTimeout: 15000,
responseTimeout: 60000,
video: true,
chromeWebSecurity: false,
scrollBehavior: 'center',
blockHosts: ['wtfismyip.com', 'images.opencollective.com', 'images-staging.opencollective.com', 'localhost:3001'],
env: {
MAILDEV_URL: 'http://localhost:1080',
codeCoverage: {
url: '/__coverage__',
},
},
fixturesFolder: 'test/cypress/fixtures',
screenshotsFolder: 'test/cypress/screenshots',
videosFolder: 'test/cypress/videos',
downloadsFolder: 'test/cypress/downloads',
e2e: {
setupNodeEvents(on, config) {
// eslint-disable-next-line n/no-unpublished-require
require('@cypress/code-coverage/task')(on, config);
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--lang=en-US');
}
});
on('task', {
// Allows to log messages from a test using `cy.task('log', 'message')`
log(...message) {
console.log(...message); // eslint-disable-line no-console
return null;
},
getTextFromPdfContent,
});
// Delete videos if the test succeeds
on('after:spec', (spec, results) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some(test => test.attempts.some(attempt => attempt.state === 'failed'));
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video);
}
}
});
config.baseUrl = process.env.WEBSITE_URL || 'http://localhost:3000';
config.env = config.env || {};
return config;
},
specPattern: 'test/cypress/integration',
supportFile: 'test/cypress/support/index.js',
baseUrl: 'http://localhost:3000',
},
});