diff --git a/test/stats/stats.test.js b/test/stats/stats.test.js index b6faa4fcabe..7eca9cf0e2e 100644 --- a/test/stats/stats.test.js +++ b/test/stats/stats.test.js @@ -3,8 +3,6 @@ const { run } = require('../utils/test-utils'); describe('stats flag', () => { - // { - // StatsGroup.validOptions().map(option => { it('should accept stats "none"', () => { const { stderr, stdout } = run(__dirname, ['--stats', 'none']); expect(stderr).toBeFalsy(); diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js new file mode 100644 index 00000000000..9acc630d895 --- /dev/null +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -0,0 +1,10 @@ +const { run } = require('../../utils/test-utils'); + +describe('Zero Config tests', () => { + it('runs when config and entry are both absent', () => { + const { stdout, stderr } = run(__dirname, [], false); + // Entry file is absent, should log the Error from the compiler + expect(stdout).toContain("Error: Can't resolve './src'"); + expect(stderr).toBeFalsy(); + }); +}); diff --git a/test/zero-config/entry-present/src/index.js b/test/zero-config/entry-present/src/index.js new file mode 100644 index 00000000000..655f0d1539f --- /dev/null +++ b/test/zero-config/entry-present/src/index.js @@ -0,0 +1 @@ +console.log("Shoyo") diff --git a/test/zero-config/entry-present/zero-config.test.js b/test/zero-config/entry-present/zero-config.test.js new file mode 100644 index 00000000000..556db6c6b49 --- /dev/null +++ b/test/zero-config/entry-present/zero-config.test.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('Zero Config tests', () => { + it('runs when no config is supplied but entry is present', () => { + const { stdout, stderr } = run(__dirname, [], false); + // Should be able to find the entry file + expect(stdout).toContain('./src/index.js'); + // Should output at the default output dir and filename + expect(stdout).toContain('Entrypoint main = main.js'); + // check that the output file exists + expect(fs.existsSync(path.join(__dirname, '/dist/main.js'))).toBeTruthy(); + expect(stderr).toBeFalsy(); + }); +}); diff --git a/test/zero-config/with-config/index.js b/test/zero-config/with-config/index.js new file mode 100644 index 00000000000..fcb6413e9b3 --- /dev/null +++ b/test/zero-config/with-config/index.js @@ -0,0 +1 @@ +console.log("Naruto") diff --git a/test/zero-config/with-config/webpack.config.js b/test/zero-config/with-config/webpack.config.js new file mode 100644 index 00000000000..6593a7a44a3 --- /dev/null +++ b/test/zero-config/with-config/webpack.config.js @@ -0,0 +1,6 @@ +module.exports = { + mode: 'development', + output: { + filename: 'test-output.js', + }, +}; diff --git a/test/zero-config/with-config/zero-config-entry.test.js b/test/zero-config/with-config/zero-config-entry.test.js new file mode 100644 index 00000000000..53825d5ad8f --- /dev/null +++ b/test/zero-config/with-config/zero-config-entry.test.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('Zero Config', () => { + it('runs when config is present but not supplied via flag', () => { + const { stdout, stderr } = run(__dirname, [], false); + // default entry should be used + expect(stdout).toContain('./index.js'); + // should pick up the output path from config + expect(stdout).toContain('Entrypoint main = test-output'); + // check that the output file exists + expect(fs.existsSync(path.join(__dirname, '/dist/test-output.js'))).toBeTruthy(); + expect(stderr).toBeFalsy(); + }); +});