-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcypress.config.js
48 lines (43 loc) · 1.6 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
const path = require('path');
const fs = require('fs');
const { defineConfig } = require('cypress');
const { initPlugin } = require('@frsource/cypress-plugin-visual-regression-diff/plugins');
module.exports = defineConfig({
chromeWebSecurity: false,
video: false,
fixturesFolder: 'tests/e2e/fixtures',
screenshotsFolder: 'tests/e2e/screenshots',
videosFolder: 'tests/e2e/videos',
env:
process.env.CI === 'true'
? {}
: {
pluginVisualRegressionImagesPath: '{spec_path}/__image_snapshots_local__',
},
e2e: {
specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'tests/e2e/support/index.js',
experimentalRunAllSpecs: true,
setupNodeEvents(on, config) {
initPlugin(on, config);
const videoPath = path.resolve('tests/e2e/fixtures/qr-code-videos/video.y4m');
const defaultVideoPath = path.resolve('tests/e2e/fixtures/qr-code-videos/default.y4m');
on('before:browser:launch', (browser, launchOptions) => {
if (fs.existsSync(videoPath)) fs.unlinkSync(videoPath);
fs.linkSync(defaultVideoPath, videoPath);
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push(`--use-file-for-fake-video-capture=${videoPath}`);
}
return launchOptions;
});
on('task', {
changeVideoSource(videoSource) {
const sourceVideoPath = path.join('tests/e2e/fixtures/qr-code-videos', videoSource);
fs.unlinkSync(videoPath);
fs.linkSync(sourceVideoPath, videoPath);
return null;
},
});
},
},
});