From dfb268ddc27c114e8129a4117aeeb5ed6155fbec Mon Sep 17 00:00:00 2001 From: Pavel Pustovalov Date: Fri, 31 Jan 2020 01:35:28 +0200 Subject: [PATCH] add specs --- .../test/__snapshots__/run.test.js.snap | 32 +++++++++++++++++++ .../npm-with-config-without-dev/index.js | 0 .../npm-with-config-without-dev/package.json | 12 +++++++ .../yarn-with-config-without-dev/index.js | 0 .../yarn-with-config-without-dev/package.json | 12 +++++++ .../yarn-with-config-without-dev/yarn.lock | 0 packages/size-limit/test/run.test.js | 14 ++++++++ 7 files changed, 70 insertions(+) create mode 100644 packages/size-limit/test/fixtures/npm-with-config-without-dev/index.js create mode 100644 packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json create mode 100644 packages/size-limit/test/fixtures/yarn-with-config-without-dev/index.js create mode 100644 packages/size-limit/test/fixtures/yarn-with-config-without-dev/package.json create mode 100644 packages/size-limit/test/fixtures/yarn-with-config-without-dev/yarn.lock diff --git a/packages/size-limit/test/__snapshots__/run.test.js.snap b/packages/size-limit/test/__snapshots__/run.test.js.snap index e38accc3..8ef22ed2 100644 --- a/packages/size-limit/test/__snapshots__/run.test.js.snap +++ b/packages/size-limit/test/__snapshots__/run.test.js.snap @@ -202,6 +202,22 @@ Check out docs for more complicated cases " `; +exports[`shows migration guide for npm users with size-limit config and without dependencies 1`] = ` +"Install Size Limit preset depends on type of the project + +For application, where you send JS bundle directly to users + npm install --save-dev @size-limit/preset-app +For frameworks, components and big libraries + npm install --save-dev @size-limit/preset-big-lib +For small (< 10 KB) libraries + npm install --save-dev @size-limit/preset-small-lib +Check out docs for more complicated cases + https://github.com/ai/size-limit/ + +You need to add size-limit dependency: npm install --save-dev size-limit +" +`; + exports[`shows migration guide for npm users, because of yarn 2 1`] = ` " WARN  You need to add size-limit dependency In order for the plugins to work correctly @@ -232,6 +248,22 @@ Check out docs for more complicated cases " `; +exports[`shows migration guide for yarn users with size-limit config and without dependencies 1`] = ` +"Install Size Limit preset depends on type of the project + +For application, where you send JS bundle directly to users + yarn add --dev @size-limit/preset-app +For frameworks, components and big libraries + yarn add --dev @size-limit/preset-big-lib +For small (< 10 KB) libraries + yarn add --dev @size-limit/preset-small-lib +Check out docs for more complicated cases + https://github.com/ai/size-limit/ + +You need to add size-limit dependency: yarn add --dev size-limit +" +`; + exports[`shows size-limit dependency warning 1`] = `""`; exports[`shows webpack-related help 1`] = ` diff --git a/packages/size-limit/test/fixtures/npm-with-config-without-dev/index.js b/packages/size-limit/test/fixtures/npm-with-config-without-dev/index.js new file mode 100644 index 00000000..e69de29b diff --git a/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json b/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json new file mode 100644 index 00000000..d4c89939 --- /dev/null +++ b/packages/size-limit/test/fixtures/npm-with-config-without-dev/package.json @@ -0,0 +1,12 @@ +{ + "name": "file", + "private": true, + "devDependencies": {}, + "size-limit": [ + { + "path": "index.js", + "limit": "1 KB", + "running": false + } + ] +} diff --git a/packages/size-limit/test/fixtures/yarn-with-config-without-dev/index.js b/packages/size-limit/test/fixtures/yarn-with-config-without-dev/index.js new file mode 100644 index 00000000..e69de29b diff --git a/packages/size-limit/test/fixtures/yarn-with-config-without-dev/package.json b/packages/size-limit/test/fixtures/yarn-with-config-without-dev/package.json new file mode 100644 index 00000000..d4c89939 --- /dev/null +++ b/packages/size-limit/test/fixtures/yarn-with-config-without-dev/package.json @@ -0,0 +1,12 @@ +{ + "name": "file", + "private": true, + "devDependencies": {}, + "size-limit": [ + { + "path": "index.js", + "limit": "1 KB", + "running": false + } + ] +} diff --git a/packages/size-limit/test/fixtures/yarn-with-config-without-dev/yarn.lock b/packages/size-limit/test/fixtures/yarn-with-config-without-dev/yarn.lock new file mode 100644 index 00000000..e69de29b diff --git a/packages/size-limit/test/run.test.js b/packages/size-limit/test/run.test.js index dc87d0b2..063152fb 100644 --- a/packages/size-limit/test/run.test.js +++ b/packages/size-limit/test/run.test.js @@ -121,6 +121,20 @@ it('shows migration guide for yarn 2 users', async () => { expect(history.stderr).toMatchSnapshot() }) +it('shows migration guide for yarn users: config 1, dep 0', async () => { + let [process, history] = createProcess('yarn-with-config-without-dev') + await run(process) + expect(history.exitCode).toEqual(1) + expect(history.stderr).toMatchSnapshot() +}) + +it('shows migration guide for npm users: config 1, dep 0', async () => { + let [process, history] = createProcess('npm-with-config-without-dev') + await run(process) + expect(history.exitCode).toEqual(1) + expect(history.stderr).toMatchSnapshot() +}) + it('shows migration guide for npm users, because of yarn 2', async () => { let [process, history] = createProcess('npm-without-dev-dep') await run(process)