-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathcypress.config.ts
More file actions
86 lines (79 loc) · 2.89 KB
/
cypress.config.ts
File metadata and controls
86 lines (79 loc) · 2.89 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
import 'reflect-metadata';
import * as fs from 'node:fs';
import asyncRetry from 'async-retry';
// eslint-disable-next-line import/no-extraneous-dependencies -- cypress SHOULD be a dev dependency
import { defineConfig } from 'cypress';
import { initSeed } from './integration-tests/testkit/seed';
if (!process.env.RUN_AGAINST_LOCAL_SERVICES) {
const dotenv = await import('dotenv');
dotenv.config({ path: import.meta.dirname + '/integration-tests/.env' });
}
if (process.env.RUN_AGAINST_LOCAL_SERVICES === '1') {
const dotenv = await import('dotenv');
dotenv.config({ path: import.meta.dirname + '/packages/services/server/.env.template' });
// It seems that this has to be set in the environment that the cypress cli is executed from.
// process.env.CYPRESS_BASE_URL = process.env.CYPRESS_BASE_URL ?? 'http://localhost:3000';
}
const isCI = Boolean(process.env.CI);
export const seed = initSeed();
export default defineConfig({
video: isCI,
screenshotOnRunFailure: isCI,
defaultCommandTimeout: 15_000, // sometimes the app takes longer to load, especially in the CI
retries: 2,
viewportWidth: 1280,
viewportHeight: 720,
e2e: {
setupNodeEvents(on) {
on('task', {
async seedOrg() {
const owner = await seed.createOwner();
const org = await owner.createOrg();
return {
slug: org.organization.slug,
refreshToken: owner.ownerRefreshToken,
email: owner.ownerEmail,
};
},
async purgeOIDCDomains() {
await seed.purgeOIDCDomains();
return {};
},
async forgeOIDCDNSChallenge(orgSlug: string) {
await seed.forgeOIDCDNSChallenge(orgSlug);
return {};
},
async seedTarget() {
const owner = await seed.createOwner();
const org = await owner.createOrg();
const project = await org.createProject();
const slug = `${org.organization.slug}/${project.project.slug}/${project.target.slug}`;
return {
slug,
refreshToken: owner.ownerRefreshToken,
email: owner.ownerEmail,
};
},
async getEmailConfirmationLink(input: string | { email: string; now: number }) {
const url = await seed.pollForEmailVerificationLink(input);
return url.pathname + url.search;
},
});
on('after:spec', (_, results) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some(test =>
test.attempts.some(attempt => attempt.state === 'failed'),
);
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video);
}
}
});
},
env: {
RUN_AGAINST_LOCAL_SERVICES: process.env.RUN_AGAINST_LOCAL_SERVICES || '0',
},
},
});