-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathindex.js
More file actions
60 lines (50 loc) · 2.04 KB
/
index.js
File metadata and controls
60 lines (50 loc) · 2.04 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
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const getCompareSnapshotsPlugin = require('cypress-visual-regression/dist/plugin')
const webpack = require('@cypress/webpack-preprocessor')
const { startDevServer } = require('@cypress/webpack-dev-server')
module.exports = async (on, config) => {
const webpackOptions = await require('../../webpack.config.js')()
webpackOptions.externals = {}
const options = {
// send in the options from your webpack.config.js, so it works the same
// as your app's code
webpackOptions,
watchOptions: {},
}
getCompareSnapshotsPlugin(on, config)
on('file:preprocessor', webpack(options))
on('dev-server:start', (options) => {
return startDevServer({ options, webpackConfig: webpackOptions })
})
// Disable spell checking to prevent rendering differences
on('before:browser:launch', (browser, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
Object.assign(launchOptions.preferences.default, {
browser: Object.assign(launchOptions.preferences.default.browser, { enable_spellchecking: false, enable_autospellcorrect: false }),
spellcheck: Object.assign(launchOptions.preferences.default.spellcheck, { dictionary: [] }),
})
return launchOptions
}
if (browser.family === 'firefox') {
launchOptions.preferences['layout.spellcheckDefault'] = 0
return launchOptions
}
if (browser.name === 'electron') {
Object.assign(launchOptions.preferences, {
webPreferences: Object.assign(launchOptions.preferences.webPreferences, { spellcheck: false }),
})
return launchOptions
}
})
return config
}