-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathcypress.config.ts
More file actions
76 lines (63 loc) · 2.35 KB
/
cypress.config.ts
File metadata and controls
76 lines (63 loc) · 2.35 KB
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
69
70
71
72
73
74
75
76
import * as path from 'path';
import { defineConfig } from 'cypress';
import { getWebpackConfig } from './cypress/webpack.config';
import { setupNodeEvents } from './cypress/plugins';
const CORE_TESTS_DIR = 'plasma-new-hope';
const supportFilePath = path.resolve(__dirname, 'cypress', 'support', 'index.ts');
const { PACKAGE_NAME: packageName, COMPONENTS: components, RETRIES: retries = 5, BROWSER: browser } = process.env;
if (!packageName) {
throw new Error('Provide PACKAGE env to cli command');
}
const baseTestMatch = '**/*.component-test.{ts,tsx}';
const retriesCount = Number(retries);
const productName = packageName.split('-').slice(1).join('-');
const snapshotsDir = `cypress/snapshots/${productName}/`;
const getTestMatch = () => {
const componentMatchingDirs = components
? components
.split(',')
.filter((component) => Boolean(component.trim()))
.map((component) => {
const [first, ...rest] = component.trim().split('');
const componentDir = `${first.toLocaleUpperCase()}${rest.join('')}`;
return componentDir;
})
: [];
const searchDirs = packageName === 'plasma-ui' ? packageName : `{${packageName},${CORE_TESTS_DIR}}`;
if (!componentMatchingDirs.length) {
return `**/${searchDirs}/${baseTestMatch}`;
}
const matchingDirs =
componentMatchingDirs.length === 1 ? `${componentMatchingDirs[0]}` : `{${componentMatchingDirs.join(',')}}`;
return `**/${searchDirs}/**/${matchingDirs}/${baseTestMatch}`;
};
export default defineConfig({
experimentalWebKitSupport: true,
component: {
numTestsKeptInMemory: browser === 'webkit' ? 2 : 5,
specPattern: getTestMatch(),
supportFile: supportFilePath,
devServer: {
framework: 'react',
bundler: 'webpack',
webpackConfig: getWebpackConfig(),
},
justInTimeCompile: false,
setupNodeEvents,
},
env: {
snapshotsDir,
package: packageName,
a11yCheck: false,
threshold: 0.005, // это 0.5%
hasComponents: !!components,
},
retries: {
runMode: retriesCount,
openMode: 0,
},
video: false,
viewportWidth: 500,
viewportHeight: 500,
...(browser !== 'webkit' && { chromeWebSecurity: false }),
});