Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types to tests to filter by test type during testing #1342

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dev/config/src/vite/vite.test.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import VitePluginCloseAndCopy from "./vite-plugin-close-and-copy.js";
import VitePluginSourcemapExclude from "./vite-plugin-sourcemap-exclude.js";

export default function () {
const testTypeEnv = process.env.TEST_TYPE || ''
const testTypes = testTypeEnv.trim().split(",")
// @(|) globs any tests which don't have their type specified, e.g. myTest.test.ts. These are included even when filtering by test type because we don't know what type of test they are. Really, they should have their type specified.
// If we drop ^, there's a chance the tests with no type specified get ignored by accident, which we want to avoid. Ergo, include them by default.
const testTypeGlob = `@(|${testTypes.map(t => t ? `.${t.trim()}` : '').join('|')})`
console.log(`Filtering tests by type: ${testTypeGlob}`)
return defineConfig({
build: {
minify: false,
Expand All @@ -31,7 +37,7 @@ export default function () {
test: {
//root: getRootDir(),
reporters: ["basic"],
include: ["src/**/*.{test,spec}.?(c|m)[jt]s?(x)"],
include: [`src/**/*${testTypeGlob}.@(test|spec).@(mts|cts|mjs|cjs|js|ts|tsx|jsx)`],
watch: false,
watchExclude: ["**/node_modules/**", "**/dist/**"],
logHeapUsage: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"npm": ">=9"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 0",
"test": "echo \"No test specified\"",
"build": "tsc --build --verbose",
"clean": "tsc --build --clean"
},
Expand Down
Loading