diff --git a/packages/size-limit/test/__snapshots__/run.test.js.snap b/packages/size-limit/test/__snapshots__/run.test.js.snap index e38accc3..8de353a4 100644 --- a/packages/size-limit/test/__snapshots__/run.test.js.snap +++ b/packages/size-limit/test/__snapshots__/run.test.js.snap @@ -202,18 +202,26 @@ Check out docs for more complicated cases " `; -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 - npm install --save-dev size-limit +exports[`shows migration guide for npm users: config 1, dep 0 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 yarn 2 users 1`] = ` +exports[`shows migration guide for npm users: without sl dev dep 1`] = ` " WARN  You need to add size-limit dependency In order for the plugins to work correctly - yarn add --dev size-limit + npm install --save-dev size-limit " `; @@ -232,6 +240,30 @@ Check out docs for more complicated cases " `; +exports[`shows migration guide for yarn users: config 1, dep 0 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 migration guide for yarn users: without sl dev dep 1`] = ` +" WARN  You need to add size-limit dependency + In order for the plugins to work correctly + 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..ead737f3 100644 --- a/packages/size-limit/test/run.test.js +++ b/packages/size-limit/test/run.test.js @@ -114,14 +114,28 @@ it('shows migration guide for yarn users', async () => { expect(await error('legacy-yarn')).toMatchSnapshot() }) -it('shows migration guide for yarn 2 users', async () => { +it('shows migration guide for yarn users: without sl dev dep', async () => { let [process, history] = createProcess('yarn-without-dev-dep') await run(process) expect(history.exitCode).toEqual(0) expect(history.stderr).toMatchSnapshot() }) -it('shows migration guide for npm users, because of yarn 2', async () => { +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: without sl dev dep', async () => { let [process, history] = createProcess('npm-without-dev-dep') await run(process) expect(history.exitCode).toEqual(0)