-
Notifications
You must be signed in to change notification settings - Fork 7
/
cypress.config.js
63 lines (55 loc) · 1.91 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
const { defineConfig } = require("cypress");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
// This is used to store data between test steps; it's effectively a global
// variable container. The main purpose is to enable more natural expressions
// When fetching some content from a page Then checking it has expected
// properties.
const testStore = {}
async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on("file:preprocessor", browserify.default(config));
on("task", {
putValue({name, value}) {
// prevent different tests using the same name or the same feature setting
// the same value multiple times
if (name in testStore) {
throw new Error(name + ' is already set in the test store');
}
testStore[name] = value;
return true;
},
deleteValue(key) {
delete(testStore[key]);
return true;
},
getValue(name) {
return testStore[name];
},
// the following on('task') 10 lines are required for cypress.axe to use custom function to write to the log
// and could be removed if we remove dependency on cypress-axe in future
log(message) {
console.log(message);
return null;
},
table(message) {
console.table(message);
return null;
},
failed: require('cypress-failed-log/src/failed')(),
});
return config;
}
module.exports = defineConfig({
postLogoutUrl: "https://www.gov.uk/done/lasting-power-of-attorney",
rootRedirectUrl: "https://www.gov.uk/power-of-attorney/make-lasting-power",
numberOfGuidanceHelpTopics: 22,
defaultCommandTimeout: 12000,
requestTimeout: 12000,
trashAssetsBeforeRuns: false,
e2e: {
specPattern: "cypress/e2e/**/*.feature",
supportFile: "cypress/support/e2e.js",
setupNodeEvents,
},
});