From 176b08cad5c0ebb65b08608407fc3017a0abe415 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 2 Apr 2020 10:30:11 +0530 Subject: [PATCH 01/45] chore: add info package to webpack-cli --- packages/webpack-cli/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 9fffbef5945..bf205953041 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -24,6 +24,7 @@ ], "dependencies": { "@webpack-cli/package-utils": "^1.0.1-alpha.4", + "@webpack-cli/info": "^1.0.1-alpha.4", "ansi-escapes": "^4.3.1", "chalk": "^3.0.0", "command-line-args": "^5.1.1", From a0fc0dc6973f84c7ed20dd158ec18ca50b1f8282 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 29 Apr 2020 10:05:33 +0530 Subject: [PATCH 02/45] chore: typo --- test/utils/test-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 1b864c5e92b..d9cee1c6557 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -89,7 +89,7 @@ function runAndGetWatchProc(testCase, args = [], setOutput = true, input = '', f return webpackProc; } /** - * runInitWithAnswers + * runPromptWithAnswers * @param {string} location location of current working directory * @param {string[]} args CLI args to pass in * @param {string[]} answers answers to be passed to stdout for inquirer question From 21a025dbd737d52cde05030c5342f43814a1d9f5 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 29 Apr 2020 11:21:29 +0530 Subject: [PATCH 03/45] chore: test with multiple entries --- .gitignore | 3 ++ .../init-multipleEntries.test.js | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/init/multipleEntries/init-multipleEntries.test.js diff --git a/.gitignore b/.gitignore index 3c508998a3f..7cee14e3353 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ .idea .vscode +# IDE files +*.code-workspace + # Vim swap files .s[a-z][a-z] .*.s[a-z][a-z] diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js new file mode 100644 index 00000000000..6249659a5e4 --- /dev/null +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -0,0 +1,41 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const rimraf = require('rimraf'); +const { runPromptWithAnswers } = require('../../utils/test-utils'); +const firstPrompt = 'Will your application have multiple bundles?'; + +const ENTER = '\x0D'; +const genPath = path.join(__dirname, 'test-assets'); + +jest.setTimeout(400000); + +describe('init with multiple entries', () => { + beforeAll(() => { + rimraf.sync(genPath); + fs.mkdirSync(genPath); + }); + + afterAll(() => { + rimraf.sync(genPath); + }); + + it('should scaffold with multiple entries', async () => { + const { stdout } = await runPromptWithAnswers( + genPath, + ['init'], + [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], + ); + + expect(stdout).toBeTruthy(); + expect(stdout).toContain(firstPrompt); + + // Test regressively files are scaffolded + const files = ['./package.json', './src/a.js', './src/b.js', 'yarn.lock', '.yo-rc.json']; + // eslint-disable-next-line prettier/prettier + files.forEach((file) => { + expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + }); + }); +}); From 652dfd3dd37bf1bb9f1aed310e00dabc88d3454c Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 30 Apr 2020 17:21:59 +0530 Subject: [PATCH 04/45] chore: add test for css option --- .../language/css/init-language-css.test.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/init/language/css/init-language-css.test.js diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js new file mode 100644 index 00000000000..307c1651410 --- /dev/null +++ b/test/init/language/css/init-language-css.test.js @@ -0,0 +1,42 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const rimraf = require('rimraf'); +const { runPromptWithAnswers } = require('../../../utils/test-utils'); +const firstPrompt = 'Will your application have multiple bundles?'; + +const ENTER = '\x0D'; +const DOWN = '\x1B\x5B\x42'; +const genPath = path.join(__dirname, 'test-assets'); + +jest.setTimeout(400000); + +describe('init with SCSS', () => { + beforeAll(() => { + rimraf.sync(genPath); + fs.mkdirSync(genPath); + }); + + afterAll(() => { + // rimraf.sync(genPath); + }); + + it('should use SCSS', async () => { + const { stdout } = await runPromptWithAnswers( + genPath, + ['init'], + [`N${ENTER}`, ENTER, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, `Y${ENTER}`, `apple${ENTER}`], + ); + + expect(stdout).toBeTruthy(); + expect(stdout).toContain(firstPrompt); + + // Test regressively files are scaffolded + const files = ['./package.json', 'yarn.lock', '.yo-rc.json', 'webpack.config.js']; + // eslint-disable-next-line prettier/prettier + files.forEach((file) => { + expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + }); + }); +}); From 465944e77a92de12cd927c672916394babbb2595 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 12 May 2020 07:32:26 +0530 Subject: [PATCH 05/45] chore: add more tests --- .../language/css/init-language-css.test.js | 5 ++- .../init/language/js/init-language-js.test.js | 43 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/init/language/js/init-language-js.test.js diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 307c1651410..b5a26c5913e 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -19,7 +19,7 @@ describe('init with SCSS', () => { }); afterAll(() => { - // rimraf.sync(genPath); + rimraf.sync(genPath); }); it('should use SCSS', async () => { @@ -33,7 +33,8 @@ describe('init with SCSS', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', 'yarn.lock', '.yo-rc.json', 'webpack.config.js']; + const files = ['./package.json', 'yarn.lock', '.yo-rc.json', 'src/index.js']; + // eslint-disable-next-line prettier/prettier files.forEach((file) => { expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js new file mode 100644 index 00000000000..b698810808b --- /dev/null +++ b/test/init/language/js/init-language-js.test.js @@ -0,0 +1,43 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const rimraf = require('rimraf'); +const { runPromptWithAnswers } = require('../../../utils/test-utils'); +const firstPrompt = 'Will your application have multiple bundles?'; + +const ENTER = '\x0D'; +const DOWN = '\x1B\x5B\x42'; +const genPath = path.join(__dirname, 'test-assets'); + +jest.setTimeout(400000); + +describe('init with SCSS', () => { + beforeAll(() => { + rimraf.sync(genPath); + fs.mkdirSync(genPath); + }); + + afterAll(() => { + // rimraf.sync(genPath); + }); + + it('should use babel', async () => { + const { stdout } = await runPromptWithAnswers( + genPath, + ['init'], + [`N${ENTER}`, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, ENTER, ENTER], + ); + + expect(stdout).toBeTruthy(); + expect(stdout).toContain(firstPrompt); + + // Test regressively files are scaffolded + const files = ['./package.json', 'yarn.lock', '.yo-rc.json', 'tsconfig.json', 'src/index.ts']; + + // eslint-disable-next-line prettier/prettier + files.forEach((file) => { + expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + }); + }); +}); From 6537e96fe17eb5ada7ee06b79bd7d92c3ecf618d Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 12 May 2020 07:41:52 +0530 Subject: [PATCH 06/45] chore: add tests for package json --- test/init/auto/init-auto.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 8152b4e506b..3d45c267e2a 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -4,6 +4,7 @@ const fs = require('fs'); const rimraf = require('rimraf'); const { join } = require('path'); const { run } = require('../../utils/test-utils'); +const path = require('path'); const firstPrompt = 'Will your application have multiple bundles?'; const genPath = join(__dirname, 'test-assets'); @@ -38,5 +39,15 @@ describe('init auto flag', () => { files.forEach((file) => { expect(fs.existsSync(join(genPath, file))).toBeTruthy(); }); + + // Check package json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(path.join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); }); }); From 12cd10dfee3b632270d8a5a4dc0647e731124595 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 12 May 2020 07:52:47 +0530 Subject: [PATCH 07/45] chore: add more package json tests --- test/init/generator/init-inquirer.test.js | 10 ++++++++++ test/init/language/css/init-language-css.test.js | 12 ++++++++++++ test/init/language/js/init-language-js.test.js | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index e2d3784eb84..fdb63eaa275 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -33,5 +33,15 @@ describe('init', () => { files.forEach((file) => { expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); }); + + // Check package json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(path.join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); }); }); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index b5a26c5913e..312e91a481e 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -39,5 +39,17 @@ describe('init with SCSS', () => { files.forEach((file) => { expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); }); + + // Check package json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(path.join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['node-sass']).toBeTruthy(); + expect(pkgJson['devDependencies']['mini-css-extract-plugin']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); }); }); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index b698810808b..3fb6c8e0d52 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -19,7 +19,7 @@ describe('init with SCSS', () => { }); afterAll(() => { - // rimraf.sync(genPath); + rimraf.sync(genPath); }); it('should use babel', async () => { From 698320e45cb3fc66b30c979839174420899e2e1f Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 12 May 2020 08:05:18 +0530 Subject: [PATCH 08/45] chore: add typescript test --- test/init/language/js/init-language-js.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 3fb6c8e0d52..83c7dcb4920 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -22,7 +22,7 @@ describe('init with SCSS', () => { rimraf.sync(genPath); }); - it('should use babel', async () => { + it('should use typescript', async () => { const { stdout } = await runPromptWithAnswers( genPath, ['init'], @@ -39,5 +39,17 @@ describe('init with SCSS', () => { files.forEach((file) => { expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); }); + + // Check package json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(path.join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['typescript']).toBeTruthy(); + expect(pkgJson['devDependencies']['ts-loader']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); }); }); From b97f91c3acd5cd078f9c22fdbd10bb71b8001460 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 12 May 2020 11:04:43 +0530 Subject: [PATCH 09/45] chore: update language name --- test/init/language/js/init-language-js.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 83c7dcb4920..ffb44ab5470 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -12,7 +12,7 @@ const genPath = path.join(__dirname, 'test-assets'); jest.setTimeout(400000); -describe('init with SCSS', () => { +describe('init with Typescript', () => { beforeAll(() => { rimraf.sync(genPath); fs.mkdirSync(genPath); From 6b8264d0cd625403076d865183242db9b893261b Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 08:40:14 +0530 Subject: [PATCH 10/45] chore: reduce timeout by a factor of 2 --- test/init/language/css/init-language-css.test.js | 2 +- test/init/language/js/init-language-js.test.js | 2 +- test/init/multipleEntries/init-multipleEntries.test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 312e91a481e..532b375d1cf 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(400000); +jest.setTimeout(200000); describe('init with SCSS', () => { beforeAll(() => { diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index ffb44ab5470..22c7fa0bc50 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(400000); +jest.setTimeout(200000); describe('init with Typescript', () => { beforeAll(() => { diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 6249659a5e4..890164319d2 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(400000); +jest.setTimeout(200000); describe('init with multiple entries', () => { beforeAll(() => { From de0f863b5bc2be899a185fec9f66db23b85a1dc4 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 08:51:09 +0530 Subject: [PATCH 11/45] chore: use resolve instead of join --- test/init/auto/init-auto.test.js | 4 ++-- test/init/language/css/init-language-css.test.js | 4 ++-- test/init/language/js/init-language-js.test.js | 4 ++-- test/init/multipleEntries/init-multipleEntries.test.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 3d45c267e2a..9dba35c6b82 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -2,7 +2,7 @@ const fs = require('fs'); const rimraf = require('rimraf'); -const { join } = require('path'); +const { join, resolve } = require('path'); const { run } = require('../../utils/test-utils'); const path = require('path'); @@ -37,7 +37,7 @@ describe('init auto flag', () => { const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(join(genPath, file))).toBeTruthy(); + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); // Check package json is correctly configured diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 532b375d1cf..49abb5fd5ff 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -33,11 +33,11 @@ describe('init with SCSS', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', 'yarn.lock', '.yo-rc.json', 'src/index.js']; + const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); // Check package json is correctly configured diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 22c7fa0bc50..e31729b7843 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -33,11 +33,11 @@ describe('init with Typescript', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', 'yarn.lock', '.yo-rc.json', 'tsconfig.json', 'src/index.ts']; + const files = ['./package.json', './yarn.lock', './.yo-rc.json', './tsconfig.json', './src/index.ts']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); // Check package json is correctly configured diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 890164319d2..527abb7b1e4 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -32,10 +32,10 @@ describe('init with multiple entries', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './src/a.js', './src/b.js', 'yarn.lock', '.yo-rc.json']; + const files = ['./package.json', './src/a.js', './src/b.js', './yarn.lock', './.yo-rc.json']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); }); }); From 4edfbdcbad2883a7c97014b6444d8b09211d801f Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 09:00:10 +0530 Subject: [PATCH 12/45] chore: debug css test --- test/init/language/css/init-language-css.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 49abb5fd5ff..4f70c6b71a4 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -34,9 +34,11 @@ describe('init with SCSS', () => { // Test regressively files are scaffolded const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; + console.log(fs.readdirSync(genPath)); // eslint-disable-next-line prettier/prettier files.forEach((file) => { + console.log(file); expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); From 87cd37d499043edbe47a4972ea98a3bf761f25cc Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 09:16:37 +0530 Subject: [PATCH 13/45] chore: fix typo and rerun ci --- test/init/language/css/init-language-css.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 4f70c6b71a4..6fa1e84e15a 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -42,7 +42,7 @@ describe('init with SCSS', () => { expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); - // Check package json is correctly configured + // Check if package.json is correctly configured const pkgJsonTests = () => { const pkgJson = require(path.join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); From 3b5f3e8f8f462382d97abf769e11ddf918a15d9a Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 09:29:39 +0530 Subject: [PATCH 14/45] chore: remove logs --- test/init/language/css/init-language-css.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 6fa1e84e15a..c351cd768da 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -34,11 +34,9 @@ describe('init with SCSS', () => { // Test regressively files are scaffolded const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; - console.log(fs.readdirSync(genPath)); // eslint-disable-next-line prettier/prettier files.forEach((file) => { - console.log(file); expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); From bbb75cfae08827ac48e59bcb8c2b7566d77aab23 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 09:39:02 +0530 Subject: [PATCH 15/45] chore: remove check from lock file --- test/init/language/css/init-language-css.test.js | 2 +- test/init/language/js/init-language-js.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index c351cd768da..3306278a225 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -33,7 +33,7 @@ describe('init with SCSS', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; + const files = ['./package.json', './.yo-rc.json', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index e31729b7843..2bcdebb7b34 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -33,7 +33,7 @@ describe('init with Typescript', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './yarn.lock', './.yo-rc.json', './tsconfig.json', './src/index.ts']; + const files = ['./package.json', './.yo-rc.json', './tsconfig.json', './src/index.ts']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { From 51e2497bbfb8ce0ac4aa6bc39c96914ed2ac8e14 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 09:49:00 +0530 Subject: [PATCH 16/45] chore: timeout to 50 sec --- test/init/auto/init-auto.test.js | 2 +- test/init/generator/init-inquirer.test.js | 2 +- test/init/language/css/init-language-css.test.js | 3 ++- test/init/language/js/init-language-js.test.js | 2 +- test/init/multipleEntries/init-multipleEntries.test.js | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 9dba35c6b82..836a8b7941f 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -9,7 +9,7 @@ const path = require('path'); const firstPrompt = 'Will your application have multiple bundles?'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(200000); +jest.setTimeout(50000); describe('init auto flag', () => { beforeAll(() => { rimraf.sync(genPath); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index fdb63eaa275..36a3e0bf650 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(200000); +jest.setTimeout(50000); describe('init', () => { beforeAll(() => { diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 3306278a225..c7db047cc25 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(200000); +jest.setTimeout(50000); describe('init with SCSS', () => { beforeAll(() => { @@ -42,6 +42,7 @@ describe('init with SCSS', () => { // Check if package.json is correctly configured const pkgJsonTests = () => { + console.log(fs.readFileSync(path.join(genPath, './package.json'))); const pkgJson = require(path.join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 2bcdebb7b34..32ed054d13a 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(200000); +jest.setTimeout(50000); describe('init with Typescript', () => { beforeAll(() => { diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 527abb7b1e4..6c0be39c6e3 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(200000); +jest.setTimeout(50000); describe('init with multiple entries', () => { beforeAll(() => { From dfe86022d2c3012ac9018954eb0a38b93f04cab7 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 09:58:09 +0530 Subject: [PATCH 17/45] chore: increse timeout to 60s --- test/init/auto/init-auto.test.js | 2 +- test/init/generator/init-inquirer.test.js | 2 +- test/init/language/css/init-language-css.test.js | 4 ++-- test/init/language/js/init-language-js.test.js | 2 +- test/init/multipleEntries/init-multipleEntries.test.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 836a8b7941f..bcd934be433 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -9,7 +9,7 @@ const path = require('path'); const firstPrompt = 'Will your application have multiple bundles?'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(50000); +jest.setTimeout(60000); describe('init auto flag', () => { beforeAll(() => { rimraf.sync(genPath); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 36a3e0bf650..834fc1cd853 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(50000); +jest.setTimeout(60000); describe('init', () => { beforeAll(() => { diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index c7db047cc25..f281d4efff9 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(50000); +jest.setTimeout(60000); describe('init with SCSS', () => { beforeAll(() => { @@ -42,7 +42,7 @@ describe('init with SCSS', () => { // Check if package.json is correctly configured const pkgJsonTests = () => { - console.log(fs.readFileSync(path.join(genPath, './package.json'))); + console.log(fs.readFileSync(path.join(genPath, './package.json'), 'utf8')); const pkgJson = require(path.join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 32ed054d13a..0c15e905ff1 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(50000); +jest.setTimeout(60000); describe('init with Typescript', () => { beforeAll(() => { diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 6c0be39c6e3..8f76d1cd8fb 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = path.join(__dirname, 'test-assets'); -jest.setTimeout(50000); +jest.setTimeout(60000); describe('init with multiple entries', () => { beforeAll(() => { From 2014ff4be4ad29bd7286ea403db9cf6e653ec451 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 13 May 2020 10:14:20 +0530 Subject: [PATCH 18/45] chore: update inquirer test --- test/init/generator/init-inquirer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 834fc1cd853..e4b17317c00 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -22,7 +22,7 @@ describe('init', () => { }); it('should scaffold when given answers', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); From bb198444bdf585a6908bea2bc832819c7b710303 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Wed, 13 May 2020 13:06:34 +0530 Subject: [PATCH 19/45] tests: check for lock file creation and other minor tweaks --- test/init/auto/init-auto.test.js | 2 +- test/init/generator/init-inquirer.test.js | 10 +++++----- test/init/language/css/init-language-css.test.js | 11 +++++------ test/init/language/js/init-language-js.test.js | 10 +++++----- .../init/multipleEntries/init-multipleEntries.test.js | 6 +++--- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index d6493ee76b8..bcd934be433 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -34,7 +34,7 @@ describe('init auto flag', () => { expect(stdout).not.toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['sw.js', 'package.json', 'src/index.js']; + const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 398e9bd7b16..e7ca9e47291 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -1,13 +1,13 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { runPromptWithAnswers } = require('../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; -const genPath = path.join(__dirname, 'test-assets'); +const genPath = join(__dirname, 'test-assets'); jest.setTimeout(60000); @@ -28,15 +28,15 @@ describe('init', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['sw.js', 'package.json', 'src/index.js']; + const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.join(genPath, file))).toBeTruthy(); + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); // Check package json is correctly configured const pkgJsonTests = () => { - const pkgJson = require(path.join(genPath, './package.json')); + const pkgJson = require(join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index f281d4efff9..112a5e390f7 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -1,14 +1,14 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { runPromptWithAnswers } = require('../../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; -const genPath = path.join(__dirname, 'test-assets'); +const genPath = join(__dirname, 'test-assets'); jest.setTimeout(60000); @@ -33,17 +33,16 @@ describe('init with SCSS', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './.yo-rc.json', './src/index.js']; + const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); // Check if package.json is correctly configured const pkgJsonTests = () => { - console.log(fs.readFileSync(path.join(genPath, './package.json'), 'utf8')); - const pkgJson = require(path.join(genPath, './package.json')); + const pkgJson = require(join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 0c15e905ff1..dd043264808 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -1,14 +1,14 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { runPromptWithAnswers } = require('../../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; -const genPath = path.join(__dirname, 'test-assets'); +const genPath = join(__dirname, 'test-assets'); jest.setTimeout(60000); @@ -33,16 +33,16 @@ describe('init with Typescript', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './.yo-rc.json', './tsconfig.json', './src/index.ts']; + const files = ['./package.json', './yarn.lock', './.yo-rc.json', './tsconfig.json', './src/index.ts']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); // Check package json is correctly configured const pkgJsonTests = () => { - const pkgJson = require(path.join(genPath, './package.json')); + const pkgJson = require(join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 8f76d1cd8fb..0ed552c86ac 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -1,13 +1,13 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { runPromptWithAnswers } = require('../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; -const genPath = path.join(__dirname, 'test-assets'); +const genPath = join(__dirname, 'test-assets'); jest.setTimeout(60000); @@ -35,7 +35,7 @@ describe('init with multiple entries', () => { const files = ['./package.json', './src/a.js', './src/b.js', './yarn.lock', './.yo-rc.json']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { - expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); }); }); From 0a494b67a0a057e46b4d9fc3bb1b214d4a48748c Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 14 May 2020 07:59:12 +0530 Subject: [PATCH 20/45] tests: add debug statements --- test/init/auto/init-auto.test.js | 3 +++ test/init/generator/init-inquirer.test.js | 3 +++ test/init/language/css/init-language-css.test.js | 3 +++ test/init/language/js/init-language-js.test.js | 2 ++ test/init/multipleEntries/init-multipleEntries.test.js | 3 +++ 5 files changed, 14 insertions(+) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index bcd934be433..3680b0e4e97 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -35,8 +35,11 @@ describe('init auto flag', () => { // Test regressively files are scaffolded const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; + + console.log(fs.readdirSync(genPath)); // eslint-disable-next-line prettier/prettier files.forEach((file) => { + console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index e7ca9e47291..b7a67bad936 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -29,8 +29,11 @@ describe('init', () => { // Test regressively files are scaffolded const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; + console.log(fs.readdirSync(genPath)); + // eslint-disable-next-line prettier/prettier files.forEach((file) => { + console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 112a5e390f7..6b964f3ef72 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -35,8 +35,11 @@ describe('init with SCSS', () => { // Test regressively files are scaffolded const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; + console.log(fs.readdirSync(genPath)); + // eslint-disable-next-line prettier/prettier files.forEach((file) => { + console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index dd043264808..5124663c5b6 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -35,8 +35,10 @@ describe('init with Typescript', () => { // Test regressively files are scaffolded const files = ['./package.json', './yarn.lock', './.yo-rc.json', './tsconfig.json', './src/index.ts']; + console.log(fs.readdirSync(genPath)); // eslint-disable-next-line prettier/prettier files.forEach((file) => { + console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 0ed552c86ac..1d18ec80546 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -33,8 +33,11 @@ describe('init with multiple entries', () => { // Test regressively files are scaffolded const files = ['./package.json', './src/a.js', './src/b.js', './yarn.lock', './.yo-rc.json']; + console.log(fs.readdirSync(genPath)); + // eslint-disable-next-line prettier/prettier files.forEach((file) => { + console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); }); From 6851f2d3155d4aecc3ec3fd58056135c3eca7090 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 14 May 2020 08:25:11 +0530 Subject: [PATCH 21/45] chore: update test util to wait --- test/init/generator/init-inquirer.test.js | 6 +++++- test/utils/test-utils.js | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index b7a67bad936..a8a155a141d 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(60000); +jest.setTimeout(70000); describe('init', () => { beforeAll(() => { @@ -31,6 +31,10 @@ describe('init', () => { const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; console.log(fs.readdirSync(genPath)); + if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + console.log(fs.readFileSync(resolve(genPath, './yarn-error.log'), 'utf8')); + } + // eslint-disable-next-line prettier/prettier files.forEach((file) => { console.log(file); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index d9cee1c6557..7d52fff23cc 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -95,7 +95,7 @@ function runAndGetWatchProc(testCase, args = [], setOutput = true, input = '', f * @param {string[]} answers answers to be passed to stdout for inquirer question * @param {boolean} waitForOutput whether to wait for stdout before writing the next answer */ -const runPromptWithAnswers = (location, args, answers, waitForOutput = true) => { +const runPromptWithAnswers = async (location, args, answers, waitForOutput = true) => { const runner = runAndGetWatchProc(location, args, false, '', true); runner.stdin.setDefaultEncoding('utf-8'); @@ -129,7 +129,7 @@ const runPromptWithAnswers = (location, args, answers, waitForOutput = true) => ); } else { // Simulate answers by sending the answers every 2s - answers.reduce((prevAnswer, answer) => { + await answers.reduce((prevAnswer, answer) => { return prevAnswer.then(() => { return new Promise((resolvePromise) => { setTimeout(() => { @@ -141,7 +141,7 @@ const runPromptWithAnswers = (location, args, answers, waitForOutput = true) => }, Promise.resolve()); } - return new Promise((resolve) => { + return await new Promise((resolve) => { const obj = {}; let stdoutDone = false; let stderrDone = false; From ab328a223ca8d1be22697e2653ba99fae3577f2e Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 14 May 2020 09:15:12 +0530 Subject: [PATCH 22/45] chore: update tests --- test/init/generator/init-inquirer.test.js | 4 ++-- test/init/multipleEntries/init-multipleEntries.test.js | 6 +----- test/utils/test-utils.js | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index a8a155a141d..442e740dfc2 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(70000); +jest.setTimeout(100000); describe('init', () => { beforeAll(() => { @@ -22,7 +22,7 @@ describe('init', () => { }); it('should scaffold when given answers', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 1d18ec80546..df3465ccf82 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -22,11 +22,7 @@ describe('init with multiple entries', () => { }); it('should scaffold with multiple entries', async () => { - const { stdout } = await runPromptWithAnswers( - genPath, - ['init'], - [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], - ); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 7d52fff23cc..d9cee1c6557 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -95,7 +95,7 @@ function runAndGetWatchProc(testCase, args = [], setOutput = true, input = '', f * @param {string[]} answers answers to be passed to stdout for inquirer question * @param {boolean} waitForOutput whether to wait for stdout before writing the next answer */ -const runPromptWithAnswers = async (location, args, answers, waitForOutput = true) => { +const runPromptWithAnswers = (location, args, answers, waitForOutput = true) => { const runner = runAndGetWatchProc(location, args, false, '', true); runner.stdin.setDefaultEncoding('utf-8'); @@ -129,7 +129,7 @@ const runPromptWithAnswers = async (location, args, answers, waitForOutput = tru ); } else { // Simulate answers by sending the answers every 2s - await answers.reduce((prevAnswer, answer) => { + answers.reduce((prevAnswer, answer) => { return prevAnswer.then(() => { return new Promise((resolvePromise) => { setTimeout(() => { @@ -141,7 +141,7 @@ const runPromptWithAnswers = async (location, args, answers, waitForOutput = tru }, Promise.resolve()); } - return await new Promise((resolve) => { + return new Promise((resolve) => { const obj = {}; let stdoutDone = false; let stderrDone = false; From 3dc7cd7b48cc57f50686bb3edff6544fe6d11215 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 14 May 2020 10:23:39 +0530 Subject: [PATCH 23/45] chore: fix multiple entries test --- test/init/generator/init-inquirer.test.js | 8 +------- test/init/multipleEntries/init-multipleEntries.test.js | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 442e740dfc2..6a9c14b2b1c 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -22,22 +22,16 @@ describe('init', () => { }); it('should scaffold when given answers', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; - console.log(fs.readdirSync(genPath)); - - if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { - console.log(fs.readFileSync(resolve(genPath, './yarn-error.log'), 'utf8')); - } // eslint-disable-next-line prettier/prettier files.forEach((file) => { - console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index df3465ccf82..36f96108bf6 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -9,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(60000); +jest.setTimeout(100000); describe('init with multiple entries', () => { beforeAll(() => { @@ -22,7 +22,7 @@ describe('init with multiple entries', () => { }); it('should scaffold with multiple entries', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); From fb97df8c89c36e584ec16a2de9db0231dc175323 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 14 May 2020 13:18:44 +0530 Subject: [PATCH 24/45] chore: debug tests --- test/init/multipleEntries/init-multipleEntries.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 36f96108bf6..3b2f5fe05a7 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -22,7 +22,7 @@ describe('init with multiple entries', () => { }); it('should scaffold with multiple entries', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); From f6a7a61b8674efc3b3b05cfac07df89f02be9ae2 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 14:40:26 +0530 Subject: [PATCH 25/45] chore: debug tests --- .../multipleEntries/init-multipleEntries.test.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 3b2f5fe05a7..573da04350a 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -1,13 +1,13 @@ 'use strict'; const fs = require('fs'); -const { join, resolve } = require('path'); +const path = require('path'); const rimraf = require('rimraf'); const { runPromptWithAnswers } = require('../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; -const genPath = join(__dirname, 'test-assets'); +const genPath = path.join(__dirname, 'test-assets'); jest.setTimeout(100000); @@ -22,19 +22,20 @@ describe('init with multiple entries', () => { }); it('should scaffold with multiple entries', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers( + genPath, + ['init'], + [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], + ); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded const files = ['./package.json', './src/a.js', './src/b.js', './yarn.lock', './.yo-rc.json']; - console.log(fs.readdirSync(genPath)); - // eslint-disable-next-line prettier/prettier files.forEach((file) => { - console.log(file); - expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); + expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); }); }); }); From 3e631bdafdc573f80688089779d4d047919dfb65 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 14:43:29 +0530 Subject: [PATCH 26/45] test: add test for invalid scaffold --- test/init/coreFlags/init-flags.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/init/coreFlags/init-flags.test.js b/test/init/coreFlags/init-flags.test.js index 379b206a9c5..c102ee564ff 100644 --- a/test/init/coreFlags/init-flags.test.js +++ b/test/init/coreFlags/init-flags.test.js @@ -11,4 +11,9 @@ describe('init with core flags', () => { expect(stdout).not.toContain(firstPrompt); expect(stdout).toContain('Initialize a new webpack configuration'); }); + it('should throw error with invalid scaffolder package', () => { + const { stdout, stderr } = run(__dirname, ['init', '--help'], false); + console.log({ stdout, stderr }); + expect(stderr).toBeTruthy(); + }); }); From 4f3a747f604b7d1f920ef2fe67fbd0af791be816 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 14:52:09 +0530 Subject: [PATCH 27/45] chore: debug tests --- test/init/auto/init-auto.test.js | 2 -- test/init/coreFlags/init-flags.test.js | 2 +- test/init/language/css/init-language-css.test.js | 3 --- test/init/language/js/init-language-js.test.js | 5 ++--- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 3680b0e4e97..40056a78455 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -36,10 +36,8 @@ describe('init auto flag', () => { // Test regressively files are scaffolded const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; - console.log(fs.readdirSync(genPath)); // eslint-disable-next-line prettier/prettier files.forEach((file) => { - console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/coreFlags/init-flags.test.js b/test/init/coreFlags/init-flags.test.js index c102ee564ff..3ea3651ef08 100644 --- a/test/init/coreFlags/init-flags.test.js +++ b/test/init/coreFlags/init-flags.test.js @@ -12,7 +12,7 @@ describe('init with core flags', () => { expect(stdout).toContain('Initialize a new webpack configuration'); }); it('should throw error with invalid scaffolder package', () => { - const { stdout, stderr } = run(__dirname, ['init', '--help'], false); + const { stdout, stderr } = run(__dirname, ['init', 'webpack-rocks'], false); console.log({ stdout, stderr }); expect(stderr).toBeTruthy(); }); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 6b964f3ef72..112a5e390f7 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -35,11 +35,8 @@ describe('init with SCSS', () => { // Test regressively files are scaffolded const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; - console.log(fs.readdirSync(genPath)); - // eslint-disable-next-line prettier/prettier files.forEach((file) => { - console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 5124663c5b6..3394ed46a6b 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -23,22 +23,21 @@ describe('init with Typescript', () => { }); it('should use typescript', async () => { - const { stdout } = await runPromptWithAnswers( + const { stdout, stderr } = await runPromptWithAnswers( genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, ENTER, ENTER], ); + console.log(stderr); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded const files = ['./package.json', './yarn.lock', './.yo-rc.json', './tsconfig.json', './src/index.ts']; - console.log(fs.readdirSync(genPath)); // eslint-disable-next-line prettier/prettier files.forEach((file) => { - console.log(file); expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); From dd30b42c83ce15687a55aac210a6d4610bd83eab Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 14:54:07 +0530 Subject: [PATCH 28/45] chore: improve test --- test/init/coreFlags/init-flags.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/init/coreFlags/init-flags.test.js b/test/init/coreFlags/init-flags.test.js index 3ea3651ef08..2dc1a3b471c 100644 --- a/test/init/coreFlags/init-flags.test.js +++ b/test/init/coreFlags/init-flags.test.js @@ -13,7 +13,8 @@ describe('init with core flags', () => { }); it('should throw error with invalid scaffolder package', () => { const { stdout, stderr } = run(__dirname, ['init', 'webpack-rocks'], false); - console.log({ stdout, stderr }); + expect(stdout).toBeFalsy(); expect(stderr).toBeTruthy(); + expect(stderr).toContain("[webpack-cli] Promise rejection: TypeError: webpack-rocks isn't a valid name"); }); }); From 3d63bc49541929b718d38dca8788e8fb77a5fa84 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 15:09:02 +0530 Subject: [PATCH 29/45] fix: scaffold util --- packages/utils/src/scaffold.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/utils/src/scaffold.ts b/packages/utils/src/scaffold.ts index e47fc539f29..cae71ee72f2 100644 --- a/packages/utils/src/scaffold.ts +++ b/packages/utils/src/scaffold.ts @@ -21,6 +21,7 @@ import { Node } from './types/NodePath'; */ function mapOptionsToTransform(config: Config): string[] { + if (!config.webpackOptions) return config.webpackOptions; return Object.keys(config.webpackOptions).filter((k: string): boolean => PROP_TYPES.has(k)); } From 6fc57b0065ec1024880c2cbdfc03a48dbd98d796 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 15:10:53 +0530 Subject: [PATCH 30/45] fix: scaffold utility --- packages/utils/src/scaffold.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/scaffold.ts b/packages/utils/src/scaffold.ts index cae71ee72f2..97c0813815b 100644 --- a/packages/utils/src/scaffold.ts +++ b/packages/utils/src/scaffold.ts @@ -21,7 +21,7 @@ import { Node } from './types/NodePath'; */ function mapOptionsToTransform(config: Config): string[] { - if (!config.webpackOptions) return config.webpackOptions; + if (!config.webpackOptions) return []; return Object.keys(config.webpackOptions).filter((k: string): boolean => PROP_TYPES.has(k)); } From 1cca497d27ff85b993ad4a8f388c2292a4cc50db Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 15 May 2020 15:55:58 +0530 Subject: [PATCH 31/45] fix: plugin test --- test/plugin/plugin.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index 5d5ef051c31..b50bca57890 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -9,7 +9,7 @@ const pluginName = 'test-plugin'; const pluginPath = join(__dirname, pluginName); // Since scaffolding is time consuming -jest.setTimeout(20000); +jest.setTimeout(60000); describe('plugin command', () => { beforeAll(() => { From 9c50dded188273631368d27252ecbcbb63d5a1fe Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 10:44:05 +0530 Subject: [PATCH 32/45] chore: remove install dependent checks --- test/init/auto/init-auto.test.js | 2 +- test/init/generator/init-inquirer.test.js | 2 +- test/init/language/css/init-language-css.test.js | 2 +- test/init/language/js/init-language-js.test.js | 2 +- test/init/multipleEntries/init-multipleEntries.test.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 40056a78455..ec3c02b0bc5 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -34,7 +34,7 @@ describe('init auto flag', () => { expect(stdout).not.toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; + const files = ['./sw.js', './package.json', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 6a9c14b2b1c..986a6437c21 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -28,7 +28,7 @@ describe('init', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; + const files = ['./sw.js', './package.json', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 112a5e390f7..0872117086c 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -33,7 +33,7 @@ describe('init with SCSS', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './yarn.lock', './.yo-rc.json', './src/index.js']; + const files = ['./package.json', './.yo-rc.json', './src/index.js']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 3394ed46a6b..4903c8d21a8 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -34,7 +34,7 @@ describe('init with Typescript', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './yarn.lock', './.yo-rc.json', './tsconfig.json', './src/index.ts']; + const files = ['./package.json', './.yo-rc.json', './tsconfig.json', './src/index.ts']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 573da04350a..a9cbbc333fc 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -32,7 +32,7 @@ describe('init with multiple entries', () => { expect(stdout).toContain(firstPrompt); // Test regressively files are scaffolded - const files = ['./package.json', './src/a.js', './src/b.js', './yarn.lock', './.yo-rc.json']; + const files = ['./package.json', './src/a.js', './src/b.js', './.yo-rc.json']; // eslint-disable-next-line prettier/prettier files.forEach((file) => { expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); From 212c4e56c6a5415a70476f2a55f4bec053ad954b Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 12:30:59 +0530 Subject: [PATCH 33/45] chore: fix loader timeout --- test/loader/loader.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index 05dbb017cda..d6cf6e97c7e 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -12,7 +12,7 @@ const loaderName = 'test-loader'; const loaderPath = join(__dirname, loaderName); // Since scaffolding is time consuming -jest.setTimeout(20000); +jest.setTimeout(60000); describe('loader command', () => { beforeAll(() => { From 9ccb8dcc2ff21feadcf22a4f2207c14be48e5ae0 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 14:04:26 +0530 Subject: [PATCH 34/45] chore: use webpack next --- packages/generators/src/init-generator.ts | 2 +- test/init/language/js/init-language-js.test.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index e4ada4b2b02..440a803f005 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -36,7 +36,7 @@ export default class InitGenerator extends CustomGenerator { this.usingDefaults = true; this.autoGenerateConfig = opts.autoSetDefaults ? true : false; - this.dependencies = ['webpack', 'webpack-cli', 'babel-plugin-syntax-dynamic-import']; + this.dependencies = ['webpack@next', 'webpack-cli', 'babel-plugin-syntax-dynamic-import']; this.configuration = { config: { diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 4903c8d21a8..e93134957ad 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -23,13 +23,12 @@ describe('init with Typescript', () => { }); it('should use typescript', async () => { - const { stdout, stderr } = await runPromptWithAnswers( + const { stdout } = await runPromptWithAnswers( genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, ENTER, ENTER], ); - console.log(stderr); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); From b364a16219f7ed751ca5473b24dba4daafece6fe Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 18:15:02 +0530 Subject: [PATCH 35/45] chore: add test skip when install error --- test/init/auto/init-auto.test.js | 5 +++++ test/init/generator/init-inquirer.test.js | 5 +++++ test/init/language/css/init-language-css.test.js | 5 +++++ test/init/language/js/init-language-js.test.js | 5 +++++ test/init/multipleEntries/init-multipleEntries.test.js | 5 +++++ test/loader/loader.test.js | 7 ++++++- test/plugin/plugin.test.js | 7 ++++++- 7 files changed, 37 insertions(+), 2 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index ec3c02b0bc5..037b7471f13 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -33,6 +33,11 @@ describe('init auto flag', () => { expect(stdout).toBeTruthy(); expect(stdout).not.toContain(firstPrompt); + // Skip test in case yarn error log is generated + if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + return; + } + // Test regressively files are scaffolded const files = ['./sw.js', './package.json', './src/index.js']; diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 986a6437c21..3c78423c176 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -27,6 +27,11 @@ describe('init', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); + // Skip test in case yarn error log is generated + if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + return; + } + // Test regressively files are scaffolded const files = ['./sw.js', './package.json', './src/index.js']; diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 0872117086c..b33de65e0a6 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -32,6 +32,11 @@ describe('init with SCSS', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); + // Skip test in case yarn error log is generated + if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + return; + } + // Test regressively files are scaffolded const files = ['./package.json', './.yo-rc.json', './src/index.js']; diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index e93134957ad..fe304c345e1 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -32,6 +32,11 @@ describe('init with Typescript', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); + // Skip test in case yarn error log is generated + if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + return; + } + // Test regressively files are scaffolded const files = ['./package.json', './.yo-rc.json', './tsconfig.json', './src/index.ts']; diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index a9cbbc333fc..bd22a205cfc 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -31,6 +31,11 @@ describe('init with multiple entries', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); + // Skip test in case yarn error log is generated + if (fs.existsSync(path.resolve(genPath, './yarn-error.log'))) { + return; + } + // Test regressively files are scaffolded const files = ['./package.json', './src/a.js', './src/b.js', './.yo-rc.json']; // eslint-disable-next-line prettier/prettier diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index d6cf6e97c7e..fcb81c073f6 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -2,7 +2,7 @@ 'use strict'; const { existsSync } = require('fs'); -const { join } = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { run, runPromptWithAnswers } = require('../utils/test-utils'); @@ -35,6 +35,11 @@ describe('loader command', () => { expect(stdout).toContain(firstPrompt); + // Skip test in case yarn error log is generated + if (existsSync(resolve(loaderPath, './yarn-error.log'))) { + return; + } + // check if the output directory exists with the appropriate loader name expect(existsSync(join(__dirname, loaderName))).toBeTruthy(); diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index b50bca57890..70fb9034aa8 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -1,5 +1,5 @@ const { existsSync } = require('fs'); -const { join } = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { run, runPromptWithAnswers } = require('../utils/test-utils'); @@ -35,6 +35,11 @@ describe('plugin command', () => { // check if the output directory exists with the appropriate plugin name expect(existsSync(join(__dirname, pluginName))).toBeTruthy(); + // Skip test in case yarn error log is generated + if (existsSync(resolve(pluginPath, './yarn-error.log'))) { + return; + } + // Test regressively files are scaffolded const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; From 05c247c2f18ab1cf19bd0403900adffafcae9736 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 18:25:05 +0530 Subject: [PATCH 36/45] chore: debug --- test/init/auto/init-auto.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 037b7471f13..1b498bd6a61 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -28,10 +28,12 @@ describe('init auto flag', () => { }); it('should scaffold and not prompt with auto flag', () => { - const { stdout } = run(genPath, ['init', '--auto'], false); + const { stdout, stderr } = run(genPath, ['init', '--auto'], false); // Test no prompts are present expect(stdout).toBeTruthy(); expect(stdout).not.toContain(firstPrompt); + console.log(stderr); + console.log(fs.readdirSync(genPath)); // Skip test in case yarn error log is generated if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { From 548c0123a6b6ac79926a1f377f4868112d4b8b44 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 18:45:45 +0530 Subject: [PATCH 37/45] chore: skip when install fail --- test/init/auto/init-auto.test.js | 4 ++-- test/init/language/css/init-language-css.test.js | 4 ++-- test/init/language/js/init-language-js.test.js | 4 ++-- test/init/multipleEntries/init-multipleEntries.test.js | 4 ++-- test/loader/loader.test.js | 4 ++-- test/plugin/plugin.test.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 1b498bd6a61..1b5cd444aa5 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -35,8 +35,8 @@ describe('init auto flag', () => { console.log(stderr); console.log(fs.readdirSync(genPath)); - // Skip test in case yarn error log is generated - if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + // Skip test in case installation fails + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index b33de65e0a6..786308cbb5b 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -32,8 +32,8 @@ describe('init with SCSS', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); - // Skip test in case yarn error log is generated - if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + // Skip test in case installation fails + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index fe304c345e1..d16ab70ddf5 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -32,8 +32,8 @@ describe('init with Typescript', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); - // Skip test in case yarn error log is generated - if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + // Skip test in case installation fails + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index bd22a205cfc..c3f1078a517 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -31,8 +31,8 @@ describe('init with multiple entries', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); - // Skip test in case yarn error log is generated - if (fs.existsSync(path.resolve(genPath, './yarn-error.log'))) { + // Skip test in case installation fails + if (!fs.existsSync(path.resolve(genPath, './yarn.lock'))) { return; } diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index fcb81c073f6..708d6f4a4a0 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -35,8 +35,8 @@ describe('loader command', () => { expect(stdout).toContain(firstPrompt); - // Skip test in case yarn error log is generated - if (existsSync(resolve(loaderPath, './yarn-error.log'))) { + // Skip test in case installation fails + if (!existsSync(resolve(loaderPath, './yarn.lock'))) { return; } diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index 70fb9034aa8..b1ac55c9739 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -35,8 +35,8 @@ describe('plugin command', () => { // check if the output directory exists with the appropriate plugin name expect(existsSync(join(__dirname, pluginName))).toBeTruthy(); - // Skip test in case yarn error log is generated - if (existsSync(resolve(pluginPath, './yarn-error.log'))) { + // Skip test in case installation fails + if (!existsSync(resolve(pluginPath, './yarn.lock'))) { return; } From 093cad7b884280f15d9adcad0e61928d680eb92a Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 19:16:31 +0530 Subject: [PATCH 38/45] chore: fix migrate --- test/migrate/config/migrate-config.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/migrate/config/migrate-config.test.js b/test/migrate/config/migrate-config.test.js index 4c60ca6f940..615b6dd21ce 100644 --- a/test/migrate/config/migrate-config.test.js +++ b/test/migrate/config/migrate-config.test.js @@ -11,6 +11,8 @@ const outputPath = path.join(__dirname, outputDir); const outputFile = `${outputDir}/updated-webpack.config.js`; const outputFilePath = path.join(__dirname, outputFile); +jest.setTimeout(60000); + describe('migrate command', () => { beforeEach(() => { rimraf.sync(outputPath); From b3ee745f1c97015bd5f6f315e934783a97e22086 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 19:31:21 +0530 Subject: [PATCH 39/45] chore: remove logs --- test/init/auto/init-auto.test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 1b5cd444aa5..e44921fcc52 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -28,12 +28,10 @@ describe('init auto flag', () => { }); it('should scaffold and not prompt with auto flag', () => { - const { stdout, stderr } = run(genPath, ['init', '--auto'], false); + const { stdout } = run(genPath, ['init', '--auto'], false); // Test no prompts are present expect(stdout).toBeTruthy(); expect(stdout).not.toContain(firstPrompt); - console.log(stderr); - console.log(fs.readdirSync(genPath)); // Skip test in case installation fails if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { From 7be458bd25abe95fc3749779c5ebc21ed1990cc4 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 19:32:34 +0530 Subject: [PATCH 40/45] chore: remove redundant import --- test/init/auto/init-auto.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index e44921fcc52..bd772cb4b35 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -4,7 +4,6 @@ const fs = require('fs'); const rimraf = require('rimraf'); const { join, resolve } = require('path'); const { run } = require('../../utils/test-utils'); -const path = require('path'); const firstPrompt = 'Will your application have multiple bundles?'; const genPath = join(__dirname, 'test-assets'); @@ -48,7 +47,7 @@ describe('init auto flag', () => { // Check package json is correctly configured const pkgJsonTests = () => { - const pkgJson = require(path.join(genPath, './package.json')); + const pkgJson = require(join(genPath, './package.json')); expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); From 5f51c0e476a468a50fb268719a78a4cfc5878f9c Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 19 May 2020 19:59:45 +0530 Subject: [PATCH 41/45] fix: inquirer test --- test/init/generator/init-inquirer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 3c78423c176..ad8ef5bf657 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -28,7 +28,7 @@ describe('init', () => { expect(stdout).toContain(firstPrompt); // Skip test in case yarn error log is generated - if (fs.existsSync(resolve(genPath, './yarn-error.log'))) { + if (fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } From b34a48410642cbe2bf0a31c7d6030b5ac6f0790e Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 20 May 2020 09:14:32 +0530 Subject: [PATCH 42/45] chore: increase timeout for css and ts --- test/init/language/css/init-language-css.test.js | 2 +- test/init/language/js/init-language-js.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 786308cbb5b..5e973e9b564 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(60000); +jest.setTimeout(100000); describe('init with SCSS', () => { beforeAll(() => { diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index d16ab70ddf5..7b73f94a9c7 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -10,7 +10,7 @@ const ENTER = '\x0D'; const DOWN = '\x1B\x5B\x42'; const genPath = join(__dirname, 'test-assets'); -jest.setTimeout(60000); +jest.setTimeout(100000); describe('init with Typescript', () => { beforeAll(() => { From 281bd48450bc0fe23df132db288988d7bda0b43b Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 20 May 2020 19:12:56 +0530 Subject: [PATCH 43/45] chore: fix condition --- test/init/generator/init-inquirer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index ad8ef5bf657..de6244bb9fb 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -28,7 +28,7 @@ describe('init', () => { expect(stdout).toContain(firstPrompt); // Skip test in case yarn error log is generated - if (fs.existsSync(resolve(genPath, './yarn.lock'))) { + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } From a26fdb2eff2b8ae34fb7b433c281dd8f69a2255b Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 22 May 2020 14:25:53 +0530 Subject: [PATCH 44/45] chore: update comment --- test/init/generator/init-inquirer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index de6244bb9fb..e08efae10d0 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -27,7 +27,7 @@ describe('init', () => { expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); - // Skip test in case yarn error log is generated + // Skip test in case installation fails if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } From 818e21c87f203c9a68b183012929931d75dd3e9d Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 23 May 2020 10:32:18 +0530 Subject: [PATCH 45/45] chore: use webpack latest --- packages/generators/src/init-generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 440a803f005..e4ada4b2b02 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -36,7 +36,7 @@ export default class InitGenerator extends CustomGenerator { this.usingDefaults = true; this.autoGenerateConfig = opts.autoSetDefaults ? true : false; - this.dependencies = ['webpack@next', 'webpack-cli', 'babel-plugin-syntax-dynamic-import']; + this.dependencies = ['webpack', 'webpack-cli', 'babel-plugin-syntax-dynamic-import']; this.configuration = { config: {