forked from huridocs/uwazi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
60 lines (55 loc) · 1.83 KB
/
cypress.config.ts
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
import fs from 'fs';
import { defineConfig } from 'cypress';
const { initPlugin } = require('cypress-plugin-snapshots/plugin');
export default defineConfig({
viewportWidth: 1280,
viewportHeight: 768,
defaultCommandTimeout: 12000,
requestTimeout: 30000,
e2e: {
baseUrl: 'http://localhost:3000',
video: true,
retries: 2,
screenshotOnRunFailure: false,
testIsolation: false,
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
setupNodeEvents(on, config) {
// implement node event listeners here
initPlugin(on, config);
on('after:spec', (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
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);
}
}
});
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push('--window-size=1280,768');
launchOptions.args.push('--force-device-scale-factor=1');
}
if (browser.name === 'electron' && browser.isHeadless) {
launchOptions.preferences.width = 1280;
launchOptions.preferences.height = 768;
}
if (browser.name === 'firefox' && browser.isHeadless) {
launchOptions.args.push('--width=1280');
launchOptions.args.push('--height=768');
}
return launchOptions;
});
},
},
component: {
devServer: {
framework: 'react',
bundler: 'webpack',
},
specPattern: 'app/react/**/*.cy.tsx',
},
});