35a6384984
* Bump del from 6.1.1 to 7.0.0 Bumps [del](https://github.com/sindresorhus/del) from 6.1.1 to 7.0.0. - [Release notes](https://github.com/sindresorhus/del/releases) - [Commits](https://github.com/sindresorhus/del/compare/v6.1.1...v7.0.0) --- updated-dependencies: - dependency-name: del dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Apply migrations Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jon Koops <jonkoops@gmail.com>
106 lines
2.5 KiB
TypeScript
106 lines
2.5 KiB
TypeScript
import { defineConfig } from "cypress";
|
|
import { deleteAsync } from "del";
|
|
import path from "node:path";
|
|
import { build, InlineConfig } from "vite";
|
|
|
|
export default defineConfig({
|
|
projectId: "j4yhox",
|
|
screenshotsFolder: "assets/screenshots",
|
|
videosFolder: "assets/videos",
|
|
chromeWebSecurity: false,
|
|
viewportWidth: 1360,
|
|
viewportHeight: 768,
|
|
defaultCommandTimeout: 30000,
|
|
videoCompression: false,
|
|
numTestsKeptInMemory: 30,
|
|
videoUploadOnPasses: false,
|
|
retries: {
|
|
runMode: 3,
|
|
},
|
|
e2e: {
|
|
setupNodeEvents(on) {
|
|
on("file:preprocessor", vitePreprocessor);
|
|
on("after:spec", async (spec, results) => {
|
|
if (!results.video) {
|
|
return;
|
|
}
|
|
|
|
// Do we have failures for any retry attempts?
|
|
const failures = results.tests.some(({ attempts }) =>
|
|
attempts.some(({ state }) => state === "failed")
|
|
);
|
|
|
|
// Delete the video if the spec passed and no tests were retried.
|
|
if (!failures) {
|
|
await deleteAsync(results.video);
|
|
}
|
|
});
|
|
},
|
|
baseUrl: "http://localhost:8080",
|
|
slowTestThreshold: 30000,
|
|
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
|
|
},
|
|
});
|
|
|
|
const cache: Record<string, string> = {};
|
|
|
|
// See https://adamlynch.com/preprocess-cypress-tests-with-vite/
|
|
async function vitePreprocessor(file: Cypress.FileObject) {
|
|
const { filePath, outputPath, shouldWatch } = file;
|
|
|
|
if (cache[filePath]) {
|
|
return cache[filePath];
|
|
}
|
|
|
|
const filename = path.basename(outputPath);
|
|
const filenameWithoutExtension = path.basename(
|
|
outputPath,
|
|
path.extname(outputPath)
|
|
);
|
|
|
|
const viteConfig: InlineConfig = {
|
|
build: {
|
|
emptyOutDir: false,
|
|
minify: false,
|
|
outDir: path.dirname(outputPath),
|
|
sourcemap: true,
|
|
write: true,
|
|
},
|
|
};
|
|
|
|
if (filename.endsWith(".html")) {
|
|
viteConfig.build!.rollupOptions = {
|
|
input: {
|
|
[filenameWithoutExtension]: filePath,
|
|
},
|
|
};
|
|
} else {
|
|
viteConfig.build!.lib = {
|
|
entry: filePath,
|
|
fileName: () => filename,
|
|
formats: ["es"],
|
|
name: filenameWithoutExtension,
|
|
};
|
|
}
|
|
|
|
if (shouldWatch) {
|
|
// @ts-ignore
|
|
viteConfig.build.watch = true;
|
|
}
|
|
|
|
const watcher = await build(viteConfig);
|
|
|
|
if ("on" in watcher) {
|
|
watcher.on("event", (event) => {
|
|
if (event.code === "END") {
|
|
file.emit("rerun");
|
|
}
|
|
});
|
|
file.on("close", () => {
|
|
delete cache[filePath];
|
|
watcher.close();
|
|
});
|
|
}
|
|
|
|
return (cache[filePath] = outputPath);
|
|
}
|