2024-12-27 10:06:52 +00:00
|
|
|
import * as fs from 'node:fs';
|
2022-12-02 10:12:07 +00:00
|
|
|
// eslint-disable-next-line import/no-extraneous-dependencies -- cypress SHOULD be a dev dependency
|
|
|
|
|
import { defineConfig } from 'cypress';
|
2024-12-27 10:06:52 +00:00
|
|
|
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' });
|
|
|
|
|
}
|
2022-12-02 10:12:07 +00:00
|
|
|
|
2025-02-07 11:20:05 +00:00
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 13:24:34 +00:00
|
|
|
const isCI = Boolean(process.env.CI);
|
|
|
|
|
|
2024-12-27 10:06:52 +00:00
|
|
|
export const seed = initSeed();
|
|
|
|
|
|
2022-12-02 10:12:07 +00:00
|
|
|
export default defineConfig({
|
2024-04-03 13:24:34 +00:00
|
|
|
video: isCI,
|
|
|
|
|
screenshotOnRunFailure: isCI,
|
|
|
|
|
defaultCommandTimeout: 15_000, // sometimes the app takes longer to load, especially in the CI
|
|
|
|
|
retries: 2,
|
2025-12-22 10:57:07 +00:00
|
|
|
viewportWidth: 1280,
|
|
|
|
|
viewportHeight: 720,
|
2022-12-02 10:12:07 +00:00
|
|
|
e2e: {
|
2024-08-24 13:52:31 +00:00
|
|
|
setupNodeEvents(on) {
|
2024-12-27 10:06:52 +00:00
|
|
|
on('task', {
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-03 13:24:34 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-06-12 14:56:27 +00:00
|
|
|
},
|
2022-12-02 10:12:07 +00:00
|
|
|
},
|
|
|
|
|
});
|