Skip to content

chore: fix prettier and jest #4369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 14 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
**/dist
**/build
**/buildServer
**/buildClient
# Ignore all files by default
*
# Allow docs in complete-react-case to be checked
!complete-react-case/**/*.md
# Allow runtime plugin to be checked
!runtime-plugins/remote-control/app1/pick-remote.js
# Allow test files and config
!test/index.spec.js
!jest.config.cjs
# Ignore build artifacts inside included folders
complete-react-case/**/dist
complete-react-case/**/build
complete-react-case/**/buildServer
complete-react-case/**/buildClient
12 changes: 6 additions & 6 deletions complete-react-case/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A complete Webpack Module Federation Case with React.

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

It is a pure `remote`
It is a pure `remote`.

## component-app

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

## main-app

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

It is a pure host.

Expand All @@ -29,12 +29,12 @@ It is a pure host.
- `pnpm install`
- `pnpm run start`

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

# Running Cypress E2E Tests

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)
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)

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.
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.

["Best Practices, Rules amd more interesting information here](../../cypress-e2e/README.md)
[Best practices, rules and more interesting information here](../../cypress-e2e/README.md)
20 changes: 13 additions & 7 deletions complete-react-case/README_zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@

## lib-app

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

## component-app

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

它既是 host 也是 remote
它既是 `host` 也是 `remote`。

## main-app

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

# 如何使用

- `npm install`
- `npx lerna bootstrap`
- `npm run start`
- `pnpm install`
- `pnpm run start`

执行完上述命令,打开浏览器,输入`http://localhost:3002` 查看页面结果。
执行完上述命令,打开浏览器,输入 `http://localhost:3002` 查看页面结果。

# 运行 Cypress E2E 测试

- 在仓库根目录运行 `pnpm run cypress:debug` 可以以交互模式运行测试。想了解更多内容,可参阅[《如何运行测试》](../../cypress-e2e/README.md#how-to-run-tests)。
- 构建应用并在无界面模式下运行测试,可执行 `pnpm run e2e:ci`。如果测试失败,Cypress 会在示例根目录下创建 `cypress` 目录,包含截图和视频。

[最佳实践、规则和更多信息请参阅](../../cypress-e2e/README.md)
4 changes: 4 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/test'],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"submodules": "git pull --recurse-submodules",
"prettier": "prettier --write \"**/*.{js,jsx,json,md,ts,tsx}\"",
"prettier:check": "prettier --list-different \"**/*.{js,jsx,json,md,ts,tsx}\"",
"test": "jest test/index.spec.js --maxWorkers=2",
"test": "jest --config=jest.config.cjs --maxWorkers=2",
"cypress:debug": "cypress open --e2e --config-file cypress-e2e/config/cypress.config.ts --browser=chrome",
"cypress:run": "cypress run --config-file cypress-e2e/config/cypress.config.ts --browser=chrome",
"report:generate": "allure generate ./cypress/results/allure-results --clean -o ./cypress/report",
Expand Down
2 changes: 1 addition & 1 deletion runtime-plugins/remote-control/app1/pick-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const map = {
app2: 'http://localhost:3003/remoteEntry.js',
};

const CustomPlugin = (): FederationRuntimePlugin => ({
const CustomPlugin = () => ({
name: 'backend-remote-control',
beforeInit: args => {
store.name = args.options.name;
Expand Down
5 changes: 5 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const sum = (a, b) => a + b;

test('basic arithmetic works', () => {
expect(sum(1, 2)).toBe(3);
});
Loading