Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
52bbdcd
split tests out and remove README files with nothing in
LukeSheard Apr 6, 2022
9f6a858
fix tests
LukeSheard Apr 6, 2022
d7ed274
fix tests
LukeSheard Apr 7, 2022
929eaa9
remove empty snapshot
LukeSheard Apr 11, 2022
5ec3003
Create tall-roses-drum.md
LukeSheard Apr 11, 2022
ad11b59
Bump @babel/core from 7.17.8 to 7.17.9 (#1548)
dependabot[bot] Apr 7, 2022
691eebe
Bump puppeteer from 13.5.1 to 13.5.2 (#1528)
dependabot[bot] Apr 7, 2022
cdc8bf9
Bump webpack-dev-server from 4.8.0 to 4.8.1 (#1551)
dependabot[bot] Apr 7, 2022
69df257
Bump semver from 7.3.5 to 7.3.6 (#1550)
dependabot[bot] Apr 7, 2022
c6e86eb
Bump npm-packlist from 4.0.0 to 5.0.0 (#1552)
dependabot[bot] Apr 7, 2022
00a008b
Bump @types/react from 17.0.43 to 18.0.1 (#1558)
dependabot[bot] Apr 11, 2022
e684a80
Bump prettier from 2.6.0 to 2.6.2 (#1535)
dependabot[bot] Apr 11, 2022
92bc360
Bump typescript from 4.6.2 to 4.6.3 (#1508)
dependabot[bot] Apr 11, 2022
5cfd67b
Version Packages (#1520)
github-actions[bot] Apr 11, 2022
61e91fe
Bump actions/setup-node from 3.1.0 to 3.1.1 (#1563)
dependabot[bot] Apr 12, 2022
85bd1e7
Bump esbuild from 0.14.22 to 0.14.34 (#1555)
dependabot[bot] Apr 12, 2022
878f8bc
Bump @testing-library/react from 12.1.4 to 12.1.5 (#1566)
dependabot[bot] Apr 12, 2022
0ddc974
Bump browserslist from 4.19.1 to 4.20.2 (#1483)
dependabot[bot] Apr 12, 2022
5a8bdae
Bump rollup-plugin-esbuild from 4.7.2 to 4.9.1 (#1549)
dependabot[bot] Apr 12, 2022
07974ba
Dependabot/npm and yarn/rollup plugin esbuild 4.9.1 (#1569)
LukeSheard Apr 12, 2022
d587497
add test for esbuild strategy
LukeSheard Apr 12, 2022
9df932f
Merge branch 'main' into bugfix/split-tests
LukeSheard Apr 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-roses-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"modular-scripts": patch
---

Remove empty REAME.md files from packages and split tests for packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`when working with a NODE_ENV app WHEN building with esbuild can generate a js/index-FG4XHKNZ.js 1`] = `
"console.log(\\"production\\");
//# sourceMappingURL=/static/js/index-FG4XHKNZ.js.map
"
`;

exports[`when working with a NODE_ENV app WHEN building with webpack can generate a js/main.3db228f9.chunk.js 1`] = `
"(this[\\"webpackJsonpnode-env-app\\"] =
this[\\"webpackJsonpnode-env-app\\"] || []).push([
[0],
[
function (n, o, p) {
\\"use strict\\";
p.r(o), console.log(\\"production\\");
},
],
[[0, 1]],
]);
//# sourceMappingURL=main.3db228f9.chunk.js.map
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -8777,22 +8777,6 @@ exports[`When working with a nested app can generate a manifest 1`] = `
"
`;

exports[`when working with a NODE_ENV app can generate a js/main.3db228f9.chunk.js 1`] = `
"(this[\\"webpackJsonpnode-env-app\\"] =
this[\\"webpackJsonpnode-env-app\\"] || []).push([
[0],
[
function (n, o, p) {
\\"use strict\\";
p.r(o), console.log(\\"production\\");
},
],
[[0, 1]],
]);
//# sourceMappingURL=main.3db228f9.chunk.js.map
"
`;

exports[`when working with an app can generate a asset-manifest 1`] = `
"{
\\"files\\": {
Expand Down
157 changes: 157 additions & 0 deletions packages/modular-scripts/src/__tests__/app.node-env.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import execa from 'execa';
import rimraf from 'rimraf';
import tree from 'tree-view-for-tests';
import path from 'path';
import fs from 'fs-extra';
import prettier from 'prettier';
import getModularRoot from '../utils/getModularRoot';

const modularRoot = getModularRoot();

// These tests must be executed sequentially with `--runInBand`.

const packagesPath = path.join(getModularRoot(), 'packages');

function modular(str: string, opts: Record<string, unknown> = {}) {
return execa('yarnpkg', ['modular', ...str.split(' ')], {
cwd: modularRoot,
cleanup: true,
...opts,
});
}

function cleanup() {
rimraf.sync(path.join(packagesPath, 'node-env-app'));
rimraf.sync(path.join(modularRoot, 'dist/node-env-app'));

// run yarn so yarn.lock gets reset
return execa.sync('yarnpkg', ['--silent'], {
cwd: modularRoot,
});
}

beforeAll(cleanup);
afterAll(cleanup);

describe('when working with a NODE_ENV app', () => {
beforeAll(async () => {
await modular(
'add node-env-app --unstable-type app --unstable-name node-env-app',
{ stdio: 'inherit' },
);

await fs.writeFile(
path.join(modularRoot, 'packages', 'node-env-app', 'src', 'index.ts'),
`
console.log(process.env.NODE_ENV);
export {};
`,
);
});

describe('WHEN building with webpack', () => {
beforeAll(async () => {
rimraf.sync(path.join(modularRoot, 'dist/node-env-app'));

await modular('build node-env-app', {
stdio: 'inherit',
});
});

it('can build a app', () => {
expect(tree(path.join(modularRoot, 'dist', 'node-env-app')))
.toMatchInlineSnapshot(`
"node-env-app
├─ asset-manifest.json #n1rvuh
├─ favicon.ico #6pu3rg
├─ index.html #1yaenq4
├─ logo192.png #1nez7vk
├─ logo512.png #1hwqvcc
├─ manifest.json #19gah8o
├─ package.json
├─ robots.txt #1sjb8b3
└─ static
└─ js
├─ main.3db228f9.chunk.js #20y3tb
├─ main.3db228f9.chunk.js.map #qfcqz7
├─ runtime-main.a0dc6a9b.js #o5bsr9
└─ runtime-main.a0dc6a9b.js.map #10n4p35"
`);
});

it('can generate a js/main.3db228f9.chunk.js', async () => {
expect(
prettier.format(
String(
await fs.readFile(
path.join(
modularRoot,
'dist',
'node-env-app',
'static',
'js',
'main.3db228f9.chunk.js',
),
),
),
{
filepath: 'main.3db228f9.chunk.js',
},
),
).toMatchSnapshot();
});
});

describe('WHEN building with esbuild', () => {
beforeAll(async () => {
rimraf.sync(path.join(modularRoot, 'dist/node-env-app'));

await modular('build node-env-app', {
stdio: 'inherit',
env: {
USE_MODULAR_ESBUILD: 'true',
},
});
});

it('can build a app', () => {
expect(tree(path.join(modularRoot, 'dist', 'node-env-app')))
.toMatchInlineSnapshot(`
"node-env-app
├─ favicon.ico #6pu3rg
├─ index.html #yth8pd
├─ logo192.png #1nez7vk
├─ logo512.png #1hwqvcc
├─ manifest.json #19gah8o
├─ package.json
├─ robots.txt #1sjb8b3
└─ static
└─ js
├─ index-FG4XHKNZ.js #449tgl
└─ index-FG4XHKNZ.js.map #j51j3v"
`);
});

it('can generate a js/index-FG4XHKNZ.js', async () => {
expect(
prettier.format(
String(
await fs.readFile(
path.join(
modularRoot,
'dist',
'node-env-app',
'static',
'js',
'index-FG4XHKNZ.js',
),
),
),
{
filepath: 'index-FG4XHKNZ.js',
},
),
).toMatchSnapshot();
});
});
});
68 changes: 0 additions & 68 deletions packages/modular-scripts/src/__tests__/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ function cleanup() {
rimraf.sync(path.join(packagesPath, 'scoped/sample-app'));
rimraf.sync(path.join(modularRoot, 'dist/scoped-sample-app'));

rimraf.sync(path.join(packagesPath, 'node-env-app'));
rimraf.sync(path.join(modularRoot, 'dist/node-env-app'));

// run yarn so yarn.lock gets reset
return execa.sync('yarnpkg', ['--silent'], {
cwd: modularRoot,
Expand All @@ -53,71 +50,6 @@ function cleanup() {
beforeAll(cleanup);
afterAll(cleanup);

describe('when working with a NODE_ENV app', () => {
beforeAll(async () => {
await modular(
'add node-env-app --unstable-type app --unstable-name node-env-app',
{ stdio: 'inherit' },
);

await fs.writeFile(
path.join(modularRoot, 'packages', 'node-env-app', 'src', 'index.ts'),
`
console.log(process.env.NODE_ENV);

export {};
`,
);

await modular('build node-env-app', {
stdio: 'inherit',
});
});

it('can build a app', () => {
expect(tree(path.join(modularRoot, 'dist', 'node-env-app')))
.toMatchInlineSnapshot(`
"node-env-app
├─ asset-manifest.json #n1rvuh
├─ favicon.ico #6pu3rg
├─ index.html #1yaenq4
├─ logo192.png #1nez7vk
├─ logo512.png #1hwqvcc
├─ manifest.json #19gah8o
├─ package.json
├─ robots.txt #1sjb8b3
└─ static
└─ js
├─ main.3db228f9.chunk.js #20y3tb
├─ main.3db228f9.chunk.js.map #131rxqt
├─ runtime-main.a0dc6a9b.js #o5bsr9
└─ runtime-main.a0dc6a9b.js.map #10n4p35"
`);
});

it('can generate a js/main.3db228f9.chunk.js', async () => {
expect(
prettier.format(
String(
await fs.readFile(
path.join(
modularRoot,
'dist',
'node-env-app',
'static',
'js',
'main.3db228f9.chunk.js',
),
),
),
{
filepath: 'main.3db228f9.chunk.js',
},
),
).toMatchSnapshot();
});
});

describe('When working with a nested app', () => {
beforeAll(async () => {
await modular(
Expand Down
4 changes: 1 addition & 3 deletions packages/modular-scripts/src/__tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ describe('WHEN building with preserve modules', () => {
Object {
"dependencies": Object {},
"files": Array [
"README.md",
"dist-cjs",
"dist-es",
"dist-types",
"README.md",
],
"license": "UNLICENSED",
"main": "dist-cjs/index.js",
Expand All @@ -48,7 +48,6 @@ describe('WHEN building with preserve modules', () => {
expect(tree(path.join(modularRoot, 'dist', packageName)))
.toMatchInlineSnapshot(`
"sample-async-package
├─ README.md #1jv3l2q
├─ dist-cjs
│ ├─ index.js #y5z0kw
│ ├─ index.js.map #1gofapj
Expand Down Expand Up @@ -146,7 +145,6 @@ describe('WHEN building packages with private cross-package dependencies', () =>
expect(tree(path.join(modularRoot, 'dist', dependentPackage)))
.toMatchInlineSnapshot(`
"sample-depending-package
├─ README.md #1jv3l2q
├─ dist-cjs
│ ├─ index.js #1gj4b9h
│ └─ index.js.map #1v4zj6b
Expand Down
41 changes: 23 additions & 18 deletions packages/modular-scripts/src/__tests__/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as fs from 'fs-extra';
import { ModularPackageJson } from '../utils/isModularType';
import * as getModularRoot from '../utils/getModularRoot';
import { convert } from '../convert';
import tree from 'tree-view-for-tests';

jest.mock('../utils/getModularRoot');

Expand Down Expand Up @@ -77,27 +78,31 @@ describe('Converting a react app to modular app', () => {
});

it('should move the starting src folder into the modular app src folder', () => {
expect(
fs.readdirSync(
path.join(tmpFolderPath, 'packages', tmpProjectName, 'src'),
),
).toEqual(
fs.readdirSync(
path.join(__dirname, '..', '..', 'types', starterTempType, 'src'),
),
);
expect(tree(path.join(tmpFolderPath, 'packages', tmpProjectName, 'src')))
.toMatchInlineSnapshot(`
"src
├─ App.css #1o0zosm
├─ App.tsx #c80ven
├─ __tests__
│ └─ App.test.tsx #16urcos
├─ index.css #o7sk21
├─ index.tsx #zdn6mw
├─ logo.svg #1okqmlj
└─ react-app-env.d.ts #t4ygcy"
`);
});

it('should move the starting public folder into the modular app public folder', () => {
expect(
fs.readdirSync(
path.join(tmpFolderPath, 'packages', tmpProjectName, 'public'),
),
).toEqual(
fs.readdirSync(
path.join(__dirname, '..', '..', 'types', starterTempType, 'public'),
),
);
expect(tree(path.join(tmpFolderPath, 'packages', tmpProjectName, 'public')))
.toMatchInlineSnapshot(`
"public
├─ favicon.ico #6pu3rg
├─ index.html #1m6toxd
├─ logo192.png #1nez7vk
├─ logo512.png #1hwqvcc
├─ manifest.json #19gah8o
└─ robots.txt #1sjb8b3"
`);
});

it('should update tsconfig.json', () => {
Expand Down
Loading