forked from cypress-io/cypress-realworld-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
104 lines (92 loc) · 3.42 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
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
import path from "path";
import _ from "lodash";
import axios from "axios";
import dotenv from "dotenv";
import Promise from "bluebird";
import { percyHealthCheck } from "@percy/cypress/task";
import codeCoverageTask from "@cypress/code-coverage/task";
import { defineConfig } from "cypress";
import "@cypress/instrument-cra";
const { devServer } = require("@cypress/react/plugins/react-scripts");
dotenv.config({ path: ".env.local" });
dotenv.config();
const awsConfig = require(path.join(__dirname, "./aws-exports-es5.js"));
module.exports = defineConfig({
projectId: "7s5okt",
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_username: process.env.AUTH0_USERNAME,
auth0_password: process.env.AUTH0_PASSWORD,
auth0_domain: process.env.REACT_APP_AUTH0_DOMAIN,
auth0_audience: process.env.REACT_APP_AUTH0_AUDIENCE,
auth0_scope: process.env.REACT_APP_AUTH0_SCOPE,
auth0_client_id: process.env.REACT_APP_AUTH0_CLIENTID,
auth0_client_secret: process.env.AUTH0_CLIENT_SECRET,
auth_token_name: process.env.REACT_APP_AUTH_TOKEN_NAME,
// Okta
okta_username: process.env.OKTA_USERNAME,
okta_password: process.env.OKTA_PASSWORD,
okta_domain: process.env.REACT_APP_OKTA_DOMAIN,
okta_client_id: process.env.REACT_APP_OKTA_CLIENTID,
// Amazon Cognito
cognito_username: process.env.AWS_COGNITO_USERNAME,
cognito_password: process.env.AWS_COGNITO_PASSWORD,
awsConfig: awsConfig.default,
// Google
googleRefreshToken: process.env.GOOGLE_REFRESH_TOKEN,
googleClientId: process.env.REACT_APP_GOOGLE_CLIENTID,
googleClientSecret: process.env.REACT_APP_GOOGLE_CLIENT_SECRET,
},
component: {
devServer,
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,
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", {
percyHealthCheck,
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));
},
});
codeCoverageTask(on, config);
return config;
},
},
});