Skip to content
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

build: Replace jest --ci flag with env variable #23590

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,20 @@ npm run test:coverage

### Mimic the official CI build

Our CI pipelines run on Linux machines, and the npm scripts all have the `ci` prefix.
Our CI pipelines run on Linux machines, and the top-level npm scripts all have the `ci` prefix.
To replicate the test steps from the CI pipeline locally, run the following commands for the packages or pnpm workspaces:

| Run | Non-Windows | Windows |
| -------- | -------------------------- | --------------------------------------------------- |
| PR | `npm run ci:test` | `npm run test:report && npm run test:copyresults` |
| Official | `npm run ci:test:coverage` | `npm run test:coverage && npm run test:copyresults` |

> [!IMPORTANT]
> Jest auto-detects CI environments based on environment variables, so to fully replicate the CI environment, these
> scripts set the TF_BUILD=True environment variable, which is what Azure Pipelines uses. See
> <https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#system-variables-devops-services>
> for more information.

### Run tests from within VS Code

We've checked in [VS Code configuration](https://github.com/microsoft/FluidFramework/blob/main/.vscode/launch.json)
Expand Down
4 changes: 2 additions & 2 deletions common/lib/common-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"ci:build": "npm run build:compile",
"ci:build:docs": "api-extractor run --typescript-compiler-folder ./node_modules/typescript && copyfiles -u 1 \"./_api-extractor-temp/doc-models/*\" ../../../_api-extractor-temp/",
"ci:test": "npm run test:report",
"ci:test:coverage": "npm run test:coverage",
"ci:test:coverage": "cross-env TF_BUILD=True npm run test:coverage",
"clean": "rimraf --glob _api-extractor-temp dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" nyc",
"eslint": "eslint --format stylish src",
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
Expand All @@ -46,7 +46,7 @@
"test": "npm run test:mocha && npm run test:jest",
"test:coverage": "c8 npm run test:report",
"test:jest": "jest",
"test:jest:report": "npm run test:jest -- --ci --coverage",
"test:jest:report": "npm run test:jest -- --coverage",
"test:mocha": "mocha --unhandled-rejections=strict --recursive \"dist/test/mocha/**/*.spec.*js\" --exit",
"test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
"test:mocha:report": "npm run test:mocha -- -- --reporter xunit --reporter-option output=nyc/mocha-junit-report.xml",
Expand Down
2 changes: 1 addition & 1 deletion examples/client-logger/app-insights-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test": "npm run test:jest",
"test:coverage": "npm run test:jest:coverage",
"test:jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --no-cache",
"test:jest:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --coverage --no-cache --ci",
"test:jest:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules TF_BUILD=True jest --detectOpenHandles --coverage --no-cache",
"webpack": "webpack --env production",
"webpack:dev": "webpack --env development"
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"checks:fix": "fluid-build --task checks:fix",
"ci:build": "fluid-build --task ci:build",
"ci:build:docs": "fluid-build --task ci:build:docs",
"ci:test": "npm run ci:test:mocha && npm run ci:test:jest",
"ci:test:jest": "npm run test:jest:report",
"ci:test:jest:coverage": "c8 --no-clean npm run test:jest:report",
"ci:test:mocha": "npm run test:mocha",
Expand Down
3 changes: 2 additions & 1 deletion packages/tools/devtools/devtools-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test": "npm run test:jest",
"test:coverage": "npm run test:jest:coverage",
"test:jest": "jest --detectOpenHandles",
"test:jest:coverage": "jest --detectOpenHandles --coverage --ci",
"test:jest:coverage": "cross-env TF_BUILD=True jest --detectOpenHandles --coverage",
"watch:devtools-core": "tsc --watch --project ../devtools-core/tsconfig.json --preserveWatchOutput",
"watch:devtools-view": "copyfiles -f ../../../../common/build/build-common/src/esm/package.json ../devtools-view/lib && fluid-tsc module --watch --project ../devtools-view/tsconfig.esm.json --preserveWatchOutput",
"watch:esnext": "tsc --watch --project ./tsconfig.json",
Expand Down Expand Up @@ -89,6 +89,7 @@
"@types/testing-library__jest-dom": "^5.14.5",
"concurrently": "^8.2.1",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"eslint": "~8.55.0",
"eslint-config-prettier": "~9.0.0",
"eslint-plugin-jest": "~27.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/devtools/devtools-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"test:coverage": "npm run test:jest:coverage",
"test:jest": "pnpm test:jest:cjs && echo skip per fluentui issue 30778 - pnpm test:jest:esm",
"test:jest:cjs": "jest --roots ./dist",
"test:jest:coverage": "jest --coverage --ci",
"test:jest:coverage": "cross-env TF_BUILD=True jest --coverage",
"test:jest:esm": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --roots ./lib",
"test:jest:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:jest",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist",
Expand Down
Loading
Loading