馃悰 BUG: testOptions.file does not work as expected
Quick checklist
-
I am using the latest version of Snowpack and all plugins.
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the bug
I have both a src
folder with .ts
files and a test
folder, with .ts
and also .test.ts
files.
// Snowpack Configuration File
// See all supported options: https://www.snowpack.dev/reference/configuration
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
mount: {
src: "/",
},
packageOptions: {
knownEntrypoints: ["src/extension.ts"],
external: ["vscode", ...require("module").builtinModules],
},
buildOptions: {
out: "dist",
},
testOptions: { files: ["src/test/**/*"] },
};
-
Not all the test files specified in
testOptions.files
gets excluded whenmode
isproduction
forsnowpack build
. -
Not all the test files specified in
testOptions.files
gets included whenmode
istest
forsnowpack build
. This is becausesnowpack build
always excludes what's intestOptions.files
, even whenmode
istest
.
Proposed solutions
-
The
testOptions.files
exclusion rule must be different. After all the files list gets parsed, then the exclusion glob fortestOptions.files
should be applied to make sure anything matching it will get excluded from the final build. -
snowpack build
to respect the common behavior whenmode
istest
. ThetestOptions.files
should not be excluded in such case.
Steps to reproduce
-
gh repo clone felipecrs/snowpacked-extension
(which is basicallyyo code
+npm i -D snowpack
+ changes topackage.json:scripts
+snowpack.config.js
) -
npm install
-
npx webpack build --mode production
:The
src/test
folder was not even supposed to be included in the build. -
npx webpack build --mode test
:It's behaving like before, which is missing my
*.test.ts
files from thesrc/test
folder.