Skip to content

Commit 4982fd9

Browse files
chore: fix prettier and jest (#4369)
1 parent c444ec0 commit 4982fd9

File tree

7 files changed

+44
-19
lines changed

7 files changed

+44
-19
lines changed

.prettierignore

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
**/dist
2-
**/build
3-
**/buildServer
4-
**/buildClient
1+
# Ignore all files by default
2+
*
3+
# Allow docs in complete-react-case to be checked
4+
!complete-react-case/**/*.md
5+
# Allow runtime plugin to be checked
6+
!runtime-plugins/remote-control/app1/pick-remote.js
7+
# Allow test files and config
8+
!test/index.spec.js
9+
!jest.config.cjs
10+
# Ignore build artifacts inside included folders
11+
complete-react-case/**/dist
12+
complete-react-case/**/build
13+
complete-react-case/**/buildServer
14+
complete-react-case/**/buildClient

complete-react-case/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A complete Webpack Module Federation Case with React.
1010

1111
It is a low-level or basic app, which exposes libraries like `react`, `react-dom`.
1212

13-
It is a pure `remote`
13+
It is a pure `remote`.
1414

1515
## component-app
1616

@@ -20,7 +20,7 @@ It is both host and remote.
2020

2121
## main-app
2222

23-
the top-level app, which depends on `lib-app` and `component-app`.
23+
The top-level app, which depends on `lib-app` and `component-app`.
2424

2525
It is a pure host.
2626

@@ -29,12 +29,12 @@ It is a pure host.
2929
- `pnpm install`
3030
- `pnpm run start`
3131

32-
after all the commands done, open your browser at `http://localhost:3002`, open the dev-tool's network tab to see resources loading details
32+
After running these commands, open your browser at `http://localhost:3002` and open the DevTools network tab to see resource loading details.
3333

3434
# Running Cypress E2E Tests
3535

36-
To run tests in interactive mode, run `npm run cypress:debug` from the root directory of the project. It will open Cypress Test Runner and allow to run tests in interactive mode. [More info about "How to run tests"](../../cypress-e2e/README.md#how-to-run-tests)
36+
To run tests in interactive mode, run `pnpm run cypress:debug` from the root directory of the project. It will open Cypress Test Runner and allow tests to run in interactive mode. [More info about "How to run tests"](../../cypress-e2e/README.md#how-to-run-tests)
3737

38-
To build app and run test in headless mode, run `yarn e2e:ci`. It will build app and run tests for this workspace in headless mode. If tets failed cypress will create `cypress` directory in sample root folder with screenshots and videos.
38+
To build the app and run tests in headless mode, run `pnpm run e2e:ci`. It will build the app and run tests for this workspace in headless mode. If tests fail, Cypress will create a `cypress` directory in the sample root folder with screenshots and videos.
3939

40-
["Best Practices, Rules amd more interesting information here](../../cypress-e2e/README.md)
40+
[Best practices, rules and more interesting information here](../../cypress-e2e/README.md)

complete-react-case/README_zh-cn.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@
88

99
## lib-app
1010

11-
底层 App,暴露了一些库模块:`react``react-dom`。它是一个纯粹的 remote
11+
底层 App,暴露了一些库模块:`react``react-dom`。它是一个纯粹的 `remote`
1212

1313
## component-app
1414

1515
组件层 App,依赖`lib-app`暴露的`react``react-dom`模块,也暴露了一些组件如对话框`Dialog`、按钮`Button`给另一个 app:`main-app`
1616

17-
它既是 host 也是 remote
17+
它既是 `host` 也是 `remote`
1818

1919
## main-app
2020

21-
上层 App,依赖`lib-app``component-app`应用。它也是一个纯粹 host。
21+
上层 App,依赖`lib-app``component-app`应用。它也是一个纯粹的 `host`
2222

2323
# 如何使用
2424

25-
- `npm install`
26-
- `npx lerna bootstrap`
27-
- `npm run start`
25+
- `pnpm install`
26+
- `pnpm run start`
2827

29-
执行完上述命令,打开浏览器,输入`http://localhost:3002` 查看页面结果。
28+
执行完上述命令,打开浏览器,输入 `http://localhost:3002` 查看页面结果。
29+
30+
# 运行 Cypress E2E 测试
31+
32+
- 在仓库根目录运行 `pnpm run cypress:debug` 可以以交互模式运行测试。想了解更多内容,可参阅[《如何运行测试》](../../cypress-e2e/README.md#how-to-run-tests)
33+
- 构建应用并在无界面模式下运行测试,可执行 `pnpm run e2e:ci`。如果测试失败,Cypress 会在示例根目录下创建 `cypress` 目录,包含截图和视频。
34+
35+
[最佳实践、规则和更多信息请参阅](../../cypress-e2e/README.md)

jest.config.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
roots: ['<rootDir>/test'],
4+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"submodules": "git pull --recurse-submodules",
5050
"prettier": "prettier --write \"**/*.{js,jsx,json,md,ts,tsx}\"",
5151
"prettier:check": "prettier --list-different \"**/*.{js,jsx,json,md,ts,tsx}\"",
52-
"test": "jest test/index.spec.js --maxWorkers=2",
52+
"test": "jest --config=jest.config.cjs --maxWorkers=2",
5353
"cypress:debug": "cypress open --e2e --config-file cypress-e2e/config/cypress.config.ts --browser=chrome",
5454
"cypress:run": "cypress run --config-file cypress-e2e/config/cypress.config.ts --browser=chrome",
5555
"report:generate": "allure generate ./cypress/results/allure-results --clean -o ./cypress/report",

runtime-plugins/remote-control/app1/pick-remote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const map = {
88
app2: 'http://localhost:3003/remoteEntry.js',
99
};
1010

11-
const CustomPlugin = (): FederationRuntimePlugin => ({
11+
const CustomPlugin = () => ({
1212
name: 'backend-remote-control',
1313
beforeInit: args => {
1414
store.name = args.options.name;

test/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const sum = (a, b) => a + b;
2+
3+
test('basic arithmetic works', () => {
4+
expect(sum(1, 2)).toBe(3);
5+
});

0 commit comments

Comments
 (0)