Skip to content
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
7 changes: 0 additions & 7 deletions packages/cli/plugin-data-loader/jest.config.js

This file was deleted.

7 changes: 0 additions & 7 deletions packages/runtime/render/jest.config.js

This file was deleted.

5 changes: 2 additions & 3 deletions packages/runtime/render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"prepublishOnly": "only-allow-pnpm",
"dev": "modern-lib build --watch",
"build": "modern-lib build",
"test": "jest --passWithNoTests"
"test": "rstest --passWithNoTests"
},
"dependencies": {
"@modern-js/types": "workspace:*",
Expand All @@ -36,10 +36,9 @@
"@rslib/core": "0.18.3",
"@modern-js/rslib": "workspace:*",
"@modern-js/server-core": "workspace:*",
"@types/jest": "^29.5.14",
"@scripts/rstest-config": "workspace:*",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"jest": "^29.7.0",
"react": "^19.2.1",
"react-dom": "^19.2.1",
"typescript": "^5"
Expand Down
7 changes: 7 additions & 0 deletions packages/runtime/render/rstest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { withTestPreset } from '@scripts/rstest-config';

export default withTestPreset({
root: __dirname,
testEnvironment: 'node',
globals: true,
});
2 changes: 1 addition & 1 deletion packages/runtime/render/tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"declaration": false,
"baseUrl": "./",
"isolatedModules": true,
"types": ["node", "jest"]
"types": ["node", "@rstest/core/globals"]
}
}
6 changes: 2 additions & 4 deletions packages/server/babel-plugin-module-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"prepublishOnly": "only-allow-pnpm",
"dev": "modern-lib build --watch",
"build": "modern-lib build",
"test": "jest --passWithNoTests"
"test": "rstest --passWithNoTests"
},
"dependencies": {
"@swc/helpers": "^0.5.17",
Expand All @@ -49,9 +49,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
"@babel/preset-env": "^7.28.5",
"@scripts/build": "workspace:*",
"@scripts/jest-config": "workspace:*",
"common-tags": "^1.8.2",
"jest": "^29.7.0"
"common-tags": "^1.8.2"
},
"sideEffects": false,
"publishConfig": {
Expand Down
6 changes: 1 addition & 5 deletions packages/server/bff-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"prepublishOnly": "only-allow-pnpm",
"dev": "rslib build --watch",
"build": "rslib build",
"test": "jest --passWithNoTests"
"test": "rstest --passWithNoTests"
},
"dependencies": {
"@swc/helpers": "^0.5.17",
Expand All @@ -43,11 +43,7 @@
"farrow-schema": "^1.12.1"
},
"devDependencies": {
"@scripts/jest-config": "workspace:*",
"@types/jest": "^29.5.14",
"@types/node": "^20",
"jest": "^29.7.0",
"ts-jest": "^29.4.6",
"@rslib/core": "0.18.3",
"@modern-js/rslib": "workspace:*",
"typescript": "^5"
Expand Down
6 changes: 2 additions & 4 deletions packages/server/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"modern:source": "./src/index.ts",
"jsnext:source": "./src/index.ts",
"default": "./dist/cjs/index.js"
},
Expand Down Expand Up @@ -55,7 +56,7 @@
"prepublishOnly": "only-allow-pnpm",
"dev": "rslib build --watch",
"build": "rslib build",
"test": "jest --passWithNoTests"
"test": "rstest --passWithNoTests"
},
"engines": {
"node": ">=20"
Expand All @@ -78,12 +79,9 @@
"@scripts/rstest-config": "workspace:*",
"@rslib/core": "0.18.3",
"@types/cloneable-readable": "^2.0.3",
"@types/jest": "^29.5.14",
"@types/merge-deep": "^3.0.3",
"@types/node": "^20",
"http-proxy-middleware": "^2.0.9",
"jest": "^29.7.0",
"ts-jest": "^29.4.6",
"@modern-js/rslib": "workspace:*",
"typescript": "^5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/server/core/tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"jsx": "preserve",
"baseUrl": "./",
"isolatedModules": true,
"types": ["node", "jest"],
"types": ["node", "@rstest/core/globals"],
"outDir": "./dist",
"paths": {
"@base/*": ["../src/base/*"]
Expand Down
2 changes: 1 addition & 1 deletion packages/server/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"jsx": "preserve",
"baseUrl": "./",
"isolatedModules": true,
"types": ["node", "jest"]
"types": ["node", "@rstest/core/globals"]
},
"include": ["src"]
}
7 changes: 0 additions & 7 deletions packages/server/create-request/jest.config.js

This file was deleted.

6 changes: 2 additions & 4 deletions packages/server/create-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"prepublishOnly": "only-allow-pnpm",
"dev": "rslib build --watch",
"build": "rslib build",
"test": "jest --passWithNoTests"
"test": "rstest --passWithNoTests"
},
"dependencies": {
"@modern-js/runtime-utils": "workspace:*",
Expand All @@ -112,14 +112,12 @@
},
"devDependencies": {
"@modern-js/types": "workspace:*",
"@scripts/jest-config": "workspace:*",
"@scripts/rstest-config": "workspace:*",
"@rslib/core": "0.18.3",
"@modern-js/rslib": "workspace:*",
"@types/jest": "^29.5.14",
"@types/node": "^20",
"@types/node-fetch": "^2.6.13",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.7.0",
"nock": "^13.5.6",
"@types/qs": "^6.14.0",
"typescript": "^5"
Expand Down
20 changes: 20 additions & 0 deletions packages/server/create-request/rstest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { withTestPreset } from '@scripts/rstest-config';

export default {
projects: [
withTestPreset({
name: 'create-request-node',
root: __dirname,
testEnvironment: 'node',
exclude: ['tests/browser.test.ts'],
globals: true,
}),
withTestPreset({
name: 'create-request-client',
root: __dirname,
testEnvironment: 'jsdom',
include: ['tests/browser.test.ts'],
globals: true,
}),
],
};
24 changes: 13 additions & 11 deletions packages/server/create-request/tests/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/**
* @jest-environment jsdom
*/
import nock from 'nock';
import 'isomorphic-fetch';
import { configure, createRequest } from '../src/browser';

describe('configure', () => {
Expand All @@ -16,6 +12,12 @@ describe('configure', () => {
},
};

beforeAll(async () => {
delete (global as any).fetch;
// @ts-expect-error
await import('isomorphic-fetch');
});

// TODO: 如果 disableNetConnect 之后,会影响到其他的 testcase 偶发性的出现 NetConnectNotAllowedError: Nock: Disallowed net connect for "127.0.0.1:49552/" 的错误
// beforeEach(() => {
// nock.disableNetConnect();
Expand All @@ -28,7 +30,7 @@ describe('configure', () => {
test('should support custom request', async () => {
nock(url).get(path).reply(200, response);

const customRequest = jest.fn((requestPath: RequestInfo) => {
const customRequest = rs.fn((requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return fetch(finalUrl);
});
Expand All @@ -55,7 +57,7 @@ describe('configure', () => {
})
.reply(200, response);

const customRequest = jest.fn((requestPath: RequestInfo) => {
const customRequest = rs.fn((requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return fetch(finalUrl);
});
Expand All @@ -80,7 +82,7 @@ describe('configure', () => {
test('should support interceptor', async () => {
nock(url).get(path).reply(200, response);

const interceptor = jest.fn(request => (requestPath: RequestInfo) => {
const interceptor = rs.fn(request => (requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return request(finalUrl);
});
Expand All @@ -101,12 +103,12 @@ describe('configure', () => {
test('should has correct order', async () => {
nock(url).get(path).reply(200, response);

const customRequest = jest.fn((requestPath: RequestInfo) => {
const customRequest = rs.fn((requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return fetch(finalUrl);
});

const interceptor = jest.fn(request => (requestPath: RequestInfo) => {
const interceptor = rs.fn(request => (requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return request(finalUrl);
});
Expand All @@ -129,7 +131,7 @@ describe('configure', () => {
test('should support params', async () => {
nock(url).get(`${path}/modernjs`).reply(200, response);

const interceptor = jest.fn(request => (requestPath: RequestInfo) => {
const interceptor = rs.fn(request => (requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return request(finalUrl);
});
Expand All @@ -149,7 +151,7 @@ describe('configure', () => {
test('should support params with schema', async () => {
nock(url).get(`${path}/modernjs`).reply(200, response);

const interceptor = jest.fn(request => (requestPath: RequestInfo) => {
const interceptor = rs.fn(request => (requestPath: RequestInfo) => {
const finalUrl = `${url}${requestPath as string}`;
return request(finalUrl);
});
Expand Down
Loading