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

fix(config): ignore entry options #479

Merged
merged 1 commit into from Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/karma-webpack/controller.js
Expand Up @@ -25,7 +25,7 @@ class KW_Controller {
console.warn(
`
karma-webpack does not currently support customized filenames via
webpack output.filename, if this is something you need consider opening a ticket.
webpack output.filename, if this is something you need consider opening an issue.
defaulting ${newOptions.output.filename} to [name].js.`.trim()
);
delete newOptions.output.filename;
Expand Down
10 changes: 10 additions & 0 deletions lib/karma-webpack/preprocessor.js
Expand Up @@ -59,6 +59,16 @@ function KW_Preprocessor(config, emitter) {
entry: configToWebpackEntries(config),
watch: config.autoWatch,
});

if (config.webpack.entry) {
console.warn(`
karma-webpack does not currently support custom entries, if this is something you need,
consider opening an issue.
ignoring attempt to set the entry option...
`);
delete config.webpack.entry;
}

controller.updateWebpackOptions(config.webpack);
controller.karmaEmitter = emitter;
}
Expand Down
68 changes: 68 additions & 0 deletions test/integration/scenarios/basic-setup/custom-entry-path.test.js
@@ -0,0 +1,68 @@
/* eslint-disable prettier/prettier */

import karmaChromeLauncher from 'karma-chrome-launcher';
import karmaMocha from 'karma-mocha';
import karmaChai from 'karma-chai';

import Scenario from '../../utils/scenario';

process.env.CHROME_BIN = require('puppeteer').executablePath();

const path = require('path');

const karmaWebpack = require('../../../../lib/index');

// The karma server integration tests take longer than the jest 5 sec default,
// we will give them 30 seconds to complete.
const KARMA_SERVER_TIMEOUT = 30 * 1000;

describe('A basic karma-webpack setup', () => {
let scenario;

const TEST_PATH = path.resolve(__dirname, './index.scenario.js');

const config = {
frameworks: ['mocha', 'chai', 'webpack'],
files: [{ pattern: TEST_PATH }],
preprocessors: { [TEST_PATH]: ['webpack'] },
webpack: {
devtool: false,
entry: './test.js',
},
browsers: ['ChromeHeadless'],
// Explicitly turn off reporters so the simulated test results are not confused with the actual results.
reporters: [],
plugins: [karmaWebpack, karmaChromeLauncher, karmaMocha, karmaChai],
port: 2389,
logLevel: 'ERROR',
singleRun: true
};

beforeAll((done) => {
Scenario.run(config)
.then((res) => {
scenario = res;
})
.catch((err) => console.error('Integration Scenario Failed: ', err))
.finally(() => done());
}, KARMA_SERVER_TIMEOUT);

// karma-webpack should ignore the entry option and throw a warning.

it('should have an exit code of 1 because it contains a failing test', () => {
expect(scenario.exitCode).toBe(1);
})

it('should have three successful test runs', () => {
expect(scenario.success).toBe(3);
});

it('should have one failed test run', () => {
expect(scenario.failed).toBe(1);
});

it('should complete with no errors', () => {
expect(scenario.error).toBe(false);
});

});