Skip to content

Commit

Permalink
test: add
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Mar 25, 2021
1 parent d81ffab commit 0023519
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
27 changes: 16 additions & 11 deletions test/build/custom-webpack/custom-webpack.test.js
@@ -1,21 +1,26 @@
'use strict';

const { resolve } = require('path');
const { run } = require('../../utils/test-utils');

const importLocalMock = jest.fn();
jest.setMock('import-local', importLocalMock);
describe('custom-webpack', () => {
it('should use custom-webpack.js', () => {
const { exitCode, stderr, stdout } = run(__dirname, [], {
env: { WEBPACK_PACKAGE: resolve(__dirname, './custom-webpack.js') },
});

describe('import local', () => {
beforeEach(() => {
importLocalMock.mockClear();
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain('main.js');
});
it('should skip import local when supplied', () => {

it('should throw an erroe for invalid-webpack.js', () => {
const { exitCode, stderr, stdout } = run(__dirname, [], {
env: { WEBPACK_PACKAGE: './custom-webpack.js' },
env: { WEBPACK_PACKAGE: resolve(__dirname, './invalid-webpack.js') },
});
// expect(importLocalMock).toHaveBeenCalledTimes(0);
//expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();

expect(exitCode).toBe(2);
expect(stderr).toContain(`Error: Cannot find module`);
expect(stdout).toBeFalsy();
});
});
1 change: 1 addition & 0 deletions test/build/custom-webpack/src/index.js
@@ -0,0 +1 @@
console.log('hi');
3 changes: 3 additions & 0 deletions test/build/custom-webpack/webpack.config.js
@@ -0,0 +1,3 @@
module.exports = {
mode: 'production',
};

0 comments on commit 0023519

Please sign in to comment.