-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathcypress.config.ts
More file actions
138 lines (125 loc) · 4.3 KB
/
cypress.config.ts
File metadata and controls
138 lines (125 loc) · 4.3 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import path from "path";
import _ from "lodash";
import axios from "axios";
import dotenv from "dotenv";
import Promise from "bluebird";
import codeCoverageTask from "@cypress/code-coverage/task";
import { defineConfig } from "cypress";
import viteConfig from "./vite.cypress.config.ts";
dotenv.config({ path: ".env.local" });
dotenv.config();
let awsConfig = {
default: undefined,
};
try {
awsConfig = require(path.join(__dirname, "./aws-exports-es5.js"));
} catch (e) {}
export default defineConfig({
projectId: "7s5okt",
retries: {
runMode: 2,
},
env: {
apiUrl: "http://localhost:3001",
mobileViewportWidthBreakpoint: 414,
coverage: false,
codeCoverage: {
url: "http://localhost:3001/__coverage__",
exclude: "cypress/**/*.*",
},
defaultPassword: process.env.SEED_DEFAULT_USER_PASSWORD,
paginationPageSize: process.env.PAGINATION_PAGE_SIZE,
// Auth0
auth0_domain: process.env.VITE_AUTH0_DOMAIN,
// Okta
okta_domain: process.env.VITE_OKTA_DOMAIN,
okta_client_id: process.env.VITE_OKTA_CLIENTID,
okta_programmatic_login: process.env.OKTA_PROGRAMMATIC_LOGIN || false,
// Amazon Cognito
cognito_domain: process.env.AWS_COGNITO_DOMAIN,
cognito_programmatic_login: false,
awsConfig: awsConfig.default,
// Google
googleClientId: process.env.VITE_GOOGLE_CLIENTID,
},
component: {
devServer: {
framework: "react",
bundler: "vite",
viteConfig,
},
specPattern: "src/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "cypress/support/component.ts",
setupNodeEvents(on, config) {
codeCoverageTask(on, config);
return config;
},
},
e2e: {
baseUrl: "http://localhost:3000",
specPattern: "cypress/tests/**/*.spec.{js,jsx,ts,tsx}",
supportFile: "cypress/support/e2e.ts",
viewportHeight: 1000,
viewportWidth: 1280,
experimentalRunAllSpecs: true,
experimentalStudio: true,
setupNodeEvents(on, config) {
const testDataApiEndpoint = `${config.env.apiUrl}/testData`;
const queryDatabase = ({ entity, query }, callback) => {
const fetchData = async (attrs) => {
const { data } = await axios.get(`${testDataApiEndpoint}/${entity}`);
return callback(data, attrs);
};
return Array.isArray(query) ? Promise.map(query, fetchData) : fetchData(query);
};
on("task", {
async "db:seed"() {
// seed database with test data
const { data } = await axios.post(`${testDataApiEndpoint}/seed`);
return data;
},
// fetch test data from a database (MySQL, PostgreSQL, etc...)
"filter:database"(queryPayload) {
return queryDatabase(queryPayload, (data, attrs) => _.filter(data.results, attrs));
},
"find:database"(queryPayload) {
return queryDatabase(queryPayload, (data, attrs) => _.find(data.results, attrs));
},
getAuth0Credentials() {
const username = process.env.AUTH0_USERNAME;
const password = process.env.AUTH0_PASSWORD;
if (!username || !password) {
throw new Error("AUTH0_USERNAME and AUTH0_PASSWORD must be set");
}
return { username, password };
},
getOktaCredentials() {
const username = process.env.OKTA_USERNAME;
const password = process.env.OKTA_PASSWORD;
if (!username || !password) {
throw new Error("OKTA_USERNAME and OKTA_PASSWORD must be set");
}
return { username, password };
},
getCognitoCredentials() {
const username = process.env.AWS_COGNITO_USERNAME;
const password = process.env.AWS_COGNITO_PASSWORD;
if (!username || !password) {
throw new Error("AWS_COGNITO_USERNAME and AWS_COGNITO_PASSWORD must be set");
}
return { username, password };
},
getGoogleCredentials() {
const refreshToken = process.env.GOOGLE_REFRESH_TOKEN;
const clientSecret = process.env.VITE_GOOGLE_CLIENT_SECRET;
if (!refreshToken || !clientSecret) {
throw new Error("GOOGLE_REFRESH_TOKEN and VITE_GOOGLE_CLIENT_SECRET must be set");
}
return { refreshToken, clientSecret };
},
});
codeCoverageTask(on, config);
return config;
},
},
});