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

ReferenceError: exports is not defined #625

Open
bnn16 opened this issue Aug 1, 2024 · 0 comments
Open

ReferenceError: exports is not defined #625

bnn16 opened this issue Aug 1, 2024 · 0 comments

Comments

@bnn16
Copy link

bnn16 commented Aug 1, 2024

I seem to have this issue that I can't seem to fix. I updated my main tsconfig recently and for some reason my tests now fail.
Full log can be found here : https://pastebin.com/fTHJZ77S ( I deleted majority of the repeating stuff from debug )

karma versions -

"karma": "^6.4.3",
    "karma-chrome-launcher": "^3.2.0",
    "karma-jasmine": "^5.1.0",
    "karma-jasmine-dom-matchers": "^0.1.2",
    "karma-jasmine-html-reporter": "^2.1.0",
    "karma-spec-reporter": "0.0.36",
    "karma-typescript": "^5.4",
    "karma-typescript-es6-transform": "^5.5.4",

my tsconfig is

{
    "compilerOptions": {
        "baseUrl": "./",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "target": "ES6",
        "module": "ESNext",
        "moduleResolution": "node",
        "noFallthroughCasesInSwitch": true,
        "noErrorTruncation": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noImplicitOverride": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "resolveJsonModule": true,
        "sourceMap": true,
        "jsx": "react-jsx",
        "lib": [
            "ESNext",
            "DOM"
        ],
        "typeRoots": [
            "./declarations",
            "./node_modules/@types"
        ],
        "types": [
            "jasmine",
            "jasmine_dom_matchers",
            "node",
            "resize-observer-browser"
        ],
        "paths": {
            "@foo/foo-lab": [
                "./dist/core/"
            ],
        }
    },
    "include": [
        "lib/**/*",
        "storybook/**/*",
        "declarations/**/*",
        "performance/**/*",
        "scripts/**/*",
        "wdio.conf.mts"
    ],
    "exclude": [
        "dist"
    ],
    "angularCompilerOptions": {
        "enableI18nLegacyMessageIdFormat": false,
        "strictInjectionParameters": true,
        "strictInputAccessModifiers": true,
        "strictTemplates": true
      }
}

My tsconfig.test.json

{
    "extends": "./tsconfig.json",
    "compilerOptions": {
        "module": "CommonJS",
        "sourceMap": true,
        "noEmitOnError": true,
        "paths": {
            "worker-loader*": [
                "./lib/core/common/test/WebWorkerMock.ts"
            ],
            "@foo/foo-lab": [
                "./lib/core/"
            ]
        },
        "skipLibCheck": true,
    },
    "include": [
        "lib/**/*.ts",
        "declarations/**/*"
    ],
    "exclude": [
        "node_modules",
    ]
}

and finally my karma.conf.js

const isCoverageEnabled = () => process.argv.includes('--coverage');

module.exports = function(config) {
    config.set({
        basePath: '',
        frameworks: [
            'jasmine',
            'karma-typescript',
            'jasmine-dom-matchers',
        ],
        files: [
            'lib/core/test.config.ts',
            'lib/core/**/*.ts',
            'lib/core/**/*.scss',
        ],
        client: {
            clearContext: false,
            jasmine: { failSpecWithNoExpectations: true },
        },
        plugins: [
            'karma-spec-reporter',
            'karma-jasmine',
            'karma-jasmine-dom-matchers',
            'karma-typescript',
            'karma-jasmine-html-reporter',
            'karma-chrome-launcher',
            '@alasdair/karma-scss-preprocessor',
        ],
        preprocessors: {
            'lib/core/**/*.ts': 'karma-typescript',
            'lib/core/**/*.scss': [ 'scss' ],
        },
        reporters: [ 'spec', 'karma-typescript' ],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: [ 'Chrome' ],
        singleRun: false,
        concurrency: Infinity,
        karmaTypescriptConfig: {
            tsconfig: './tsconfig.test.json',
            reports: {
                'html': {
                    'directory': 'coverage',
                    'subdirectory': () => '',
                },
                'lcovonly': {
                    'directory': 'coverage',
                    'subdirectory': () => '',
                },
            },
            bundlerOptions: {
                sourceMap: true,
                transforms: [
                    require('karma-typescript-es6-transform')(),
                ],
            },
            coverageOptions: {
                instrumentation: isCoverageEnabled(),
                exclude: [
                    /\.(d|spec|test)\.ts$/i,
                    /(\\|\/)index\.ts$/i,
                ],
                threshold: {
                    global: {
                        statements: 60,
                        branches: 60,
                        functions: 60,
                        lines: 60,
                    },
                },
            },
        },
    });
};

For whatever reason it doesn't work. I tried #19 and #111, I can't seem to find the issue. Any idea what might be causing it

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