Skip to content

esbuild options are ignored #39

@steve-taylor

Description

@steve-taylor

Here's my config:

// karma.conf.js

module.exports = function (config) {
    config.set({
        frameworks: ['mocha', 'chai'],
        plugins: [
            'karma-esbuild',
            'karma-mocha',
            'karma-chai',
            'karma-chrome-launcher',
        ],
        files: ['packages/*/test/**/*.test.+(ts|tsx)'],
        preprocessors: {
            '**/*.+(ts|tsx)': 'esbuild',
        },
        reporters: ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        browsers: ['Chrome'],
        autoWatch: false,
        singleRun: true,
        concurrency: Infinity,

        esbuild: {
            tsconfig: 'tsconfig.spec.json',
            inject: ['./karma-esbuild-react.js'],
        },
    })
}
// karma-esbuild-react.js

import React from 'react';

import React from 'react'; is not being injected at all. Also, changing tsconfig to anything else has no effect.

Uncaught ReferenceError: React is not defined
  at /path/to/MyComponent.tsx:22:11

The documentation says that this is how you pass options to esbuild, but it appears not to be the case.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions