Skip to content

馃悰 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/**/*"] },
};
  1. Not all the test files specified in testOptions.files gets excluded when mode is production for snowpack build.

  2. Not all the test files specified in testOptions.files gets included when mode is test for snowpack build. This is because snowpack build always excludes what's in testOptions.files, even when mode is test.

Proposed solutions

  1. The testOptions.files exclusion rule must be different. After all the files list gets parsed, then the exclusion glob for testOptions.files should be applied to make sure anything matching it will get excluded from the final build.

  2. snowpack build to respect the common behavior when mode is test. The testOptions.files should not be excluded in such case.

Steps to reproduce

  1. gh repo clone felipecrs/snowpacked-extension (which is basically yo code + npm i -D snowpack + changes to package.json:scripts + snowpack.config.js)

  2. npm install

  3. npx webpack build --mode production:

    The src/test folder was not even supposed to be included in the build.

    Code_ROB0uMGOfj

  4. npx webpack build --mode test:

    It's behaving like before, which is missing my *.test.ts files from the src/test folder.

    Code_kS06KAt5EN

Link to minimal reproducible example (optional)

https://github.com/felipecrs/snowpacked-extension