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

Using inject in importMapsPlugin won't let exclude **/*.test.js files #2890

Open
Totati opened this issue Feb 17, 2025 · 0 comments
Open

Using inject in importMapsPlugin won't let exclude **/*.test.js files #2890

Totati opened this issue Feb 17, 2025 · 0 comments

Comments

@Totati
Copy link

Totati commented Feb 17, 2025

Our setup web-test-runner.config.js

const { playwrightLauncher } = require('@web/test-runner-playwright');
const { esbuildPlugin } = require('@web/dev-server-esbuild');
const resolve = require('path').resolve;
const importMapsPlugin = require('@web/dev-server-import-maps').importMapsPlugin;

module.exports = {
  ootDir: '.',
  files: ['./**/*.test.ts'],
  nodeResolve: { exportConditions: 'production' },
    browsers: [
    playwrightLauncher({
      product: 'chromium'
    })
  ],
  preserveSymlinks: true,
  plugins: [
    esbuildPlugin({
      ts: true,
      target: 'auto',
      tsconfig: resolve(__dirname, 'tsconfig.spec.json')
    }),
    importMapsPlugin({
      inject: [
        {
          importMap: {
            imports: {
              dayjs: '/node_modules/dayjs/esm/index.js',
              '/src/controllers/attribute-reflector.controller':
                '/src/controllers/__mocks__/attribute-reflector.controller.ts'
            }
          }
        }
      ]
    })
  ],
  testRunnerHtml: testFramework => `
    <html>
      <head>
        <script type="module" src="${testFramework}"></script>
        <script type="module">import 'jest-browser-globals';</script>
      </head>
    </html>
  `
};

We develop Lit web-components and every component has a component.test.ts file next to it. I created a controller and I can't create a config that lets me use the real controller in the attribute-reflector.controller.test.ts file and the mock in the rest. I don't want to test the controller in the component test, I just want to check if the components initialise it with the correct options, and calls the targetChange method when the slotted element changes.

I've tried adding another config in the inject array, defining the include the exclude filters, scoping, I've tried groups and overriding the plugins, but include, exclude and scoping works only on html files which we don't have, and the groups inherits the default plugins config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant