mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
update jest.config.js to include additional path ignores and add semver and underscore dependencies
This commit is contained in:
5
.github/workflows/unit-tests.yml
vendored
5
.github/workflows/unit-tests.yml
vendored
@@ -5,7 +5,6 @@ on:
|
||||
paths:
|
||||
- 'tools/**'
|
||||
- 'scripts/**'
|
||||
- 'jest.config.js'
|
||||
- 'package.json'
|
||||
- '.github/workflows/unit-tests.yml'
|
||||
push:
|
||||
@@ -30,8 +29,8 @@ jobs:
|
||||
with:
|
||||
node-version: 22.x
|
||||
|
||||
- name: Install deps
|
||||
run: npm install
|
||||
- name: Install unit test deps
|
||||
run: npm run install:unit
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm run test:unit
|
||||
|
||||
@@ -128,17 +128,20 @@ The repository has four test layers, each covering a different scope:
|
||||
|
||||
### Unit tests (Jest)
|
||||
|
||||
Unit tests cover pure helpers, scripts, and tool logic that does not require the Meteor runtime. They use [Jest](https://jestjs.io/) configured at the monorepo root (`jest.config.js`), targeting `tools/**/*.test.js` and `scripts/**/*.test.js`.
|
||||
Unit tests cover pure helpers, scripts, and tool logic that does not require the Meteor runtime. They use [Jest](https://jestjs.io/) configured in `tools/unit-tests/`, targeting `tools/**/*.test.js` and `scripts/**/*.test.js`.
|
||||
|
||||
```sh
|
||||
# Install dependencies (first time)
|
||||
npm run install:unit
|
||||
|
||||
# Run all unit tests
|
||||
npm run test:unit
|
||||
|
||||
# Run a specific test file
|
||||
npx jest tools/path/to/file.test.js
|
||||
npm run test:unit -- tools/path/to/file.test.js
|
||||
|
||||
# Run tests matching a name pattern
|
||||
npx jest -t "my test name"
|
||||
npm run test:unit -- -t "my test name"
|
||||
```
|
||||
|
||||
Place test files next to the module they test using the `*.test.js` naming convention. Jest will pick them up automatically.
|
||||
|
||||
10
package.json
10
package.json
@@ -16,8 +16,6 @@
|
||||
"@babel/eslint-parser": "^7.21.3",
|
||||
"@babel/eslint-plugin": "^7.19.1",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
"@swc/core": "^1.15.18",
|
||||
"@swc/jest": "^0.2.39",
|
||||
"@types/lodash.isempty": "^4.4.9",
|
||||
"@types/node": "^18.16.18",
|
||||
"@types/sockjs": "^0.3.36",
|
||||
@@ -33,14 +31,12 @@
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-react": "^7.32.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"jest": "^30.2.0",
|
||||
"prettier": "^2.8.8",
|
||||
"semver": "^7.7.2",
|
||||
"typescript": "^5.4.5",
|
||||
"underscore": "^1.13.7"
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"scripts": {
|
||||
"test:unit": "jest --config jest.config.js --passWithNoTests",
|
||||
"install:unit": "cd tools/unit-tests && npm install",
|
||||
"test:unit": "cd tools/unit-tests && npm test",
|
||||
"test:idle-bot": "node --test .github/scripts/__tests__/inactive-issues.test.js",
|
||||
"install:e2e": "cd tools/modern-tests && npm install && npx playwright install --with-deps chromium chromium-headless-shell",
|
||||
"test:e2e": "cd tools/modern-tests && npm test -- "
|
||||
|
||||
20
tools/modern-tests/README.md
Normal file
20
tools/modern-tests/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# E2E Tests
|
||||
|
||||
Isolated Jest + Playwright environment for end-to-end testing Meteor skeletons and bundler integrations.
|
||||
|
||||
The repo root `node_modules/` is used to build the dev bundle, which becomes the Meteor tool itself. Installing test deps (jest, playwright, swc, cheerio, semver, underscore) there could pull in incompatible transitive versions (e.g. lru-cache v10 vs v5) and silently break the dev bundle build or a published Meteor release. This subfolder keeps test dependencies fully isolated so they never affect how Meteor is built or shipped.
|
||||
|
||||
Tests create real Meteor projects, start dev servers, and assert behavior in a headless Chromium browser.
|
||||
|
||||
All commands below should be run from the repo root:
|
||||
|
||||
```sh
|
||||
# Install dependencies (first time)
|
||||
npm run install:e2e
|
||||
|
||||
# Run all E2E tests
|
||||
npm run test:e2e
|
||||
|
||||
# Run a specific suite
|
||||
npm run test:e2e -- --testPathPattern skeleton
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "meteor-modern-tests",
|
||||
"version": "1.0.0",
|
||||
"description": "Modern tests for Meteor",
|
||||
"description": "Isolated Jest + Playwright environment for Meteor E2E tests",
|
||||
"scripts": {
|
||||
"test": "jest --config jest.config.js"
|
||||
},
|
||||
|
||||
23
tools/unit-tests/README.md
Normal file
23
tools/unit-tests/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Unit Tests
|
||||
|
||||
Isolated Jest environment for unit-testing Meteor `tools/` and `scripts/`.
|
||||
|
||||
The repo root `node_modules/` is used to build the dev bundle, which becomes the Meteor tool itself. Installing test deps (jest, swc, semver, underscore) there could pull in incompatible transitive versions (e.g. lru-cache v10 vs v5) and silently break the dev bundle build or a published Meteor release. This subfolder keeps test dependencies fully isolated so they never affect how Meteor is built or shipped.
|
||||
|
||||
Test files use `*.test.js` next to their source.
|
||||
|
||||
All commands below should be run from the repo root:
|
||||
|
||||
```sh
|
||||
# Install dependencies (first time)
|
||||
npm run install:unit
|
||||
|
||||
# Run all unit tests
|
||||
npm run test:unit
|
||||
|
||||
# Run a specific test file
|
||||
npm run test:unit -- tools/path/to/file.test.js
|
||||
|
||||
# Run tests matching a name pattern
|
||||
npm run test:unit -- -t "my test name"
|
||||
```
|
||||
@@ -1,5 +1,9 @@
|
||||
const path = require('path');
|
||||
|
||||
const repoRoot = path.resolve(__dirname, '../..');
|
||||
|
||||
module.exports = {
|
||||
rootDir: __dirname,
|
||||
rootDir: repoRoot,
|
||||
testMatch: [
|
||||
"<rootDir>/tools/**/*.test.js",
|
||||
"<rootDir>/scripts/**/*.test.js",
|
||||
@@ -20,6 +24,9 @@ module.exports = {
|
||||
"<rootDir>/docs/",
|
||||
"<rootDir>/packages/non-core/",
|
||||
],
|
||||
modulePaths: [
|
||||
path.resolve(__dirname, 'node_modules'),
|
||||
],
|
||||
transform: {
|
||||
"^.+\\.js$": ["@swc/jest", {
|
||||
jsc: {
|
||||
4672
tools/unit-tests/package-lock.json
generated
Normal file
4672
tools/unit-tests/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
tools/unit-tests/package.json
Normal file
16
tools/unit-tests/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "meteor-unit-tests",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Isolated Jest environment for Meteor unit tests",
|
||||
"scripts": {
|
||||
"test": "jest --config jest.config.js --passWithNoTests"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/core": "^1.15.18",
|
||||
"@swc/jest": "^0.2.39",
|
||||
"jest": "^30.2.0",
|
||||
"semver": "^7.7.2",
|
||||
"underscore": "^1.13.7"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user