Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Jan 8, 2021
1 parent ec2c79f commit 5f7e76a
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions test/entry/flag-entry/entry-with-flag.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { run, isWebpack5 } = require('../../utils/test-utils');
const { run } = require('../../utils/test-utils');
const { existsSync, readFile } = require('fs');
const { resolve } = require('path');

Expand All @@ -23,23 +23,15 @@ describe('entry flag', () => {

it('should resolve the path to /src/a.js as ./src/a.js for webpack-5 only', (done) => {
const { exitCode, stderr, stdout } = run(__dirname, ['--entry', '/src/a.js']);

if (!isWebpack5) {
expect(exitCode).toBe(1);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`Module not found: Error: Can't resolve`);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy();
readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => {
expect(err).toBe(null);
expect(data).toContain('Hello from a.js');
done();
} else {
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy();
readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => {
expect(err).toBe(null);
expect(data).toContain('Hello from a.js');
done();
});
}
});
});

it('should throw error for invalid entry file', () => {
Expand Down

0 comments on commit 5f7e76a

Please sign in to comment.