switch to vitest
This commit is contained in:
parent
d2a0db01eb
commit
148668d927
9 changed files with 1189 additions and 3373 deletions
|
|
@ -1,20 +0,0 @@
|
|||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export default {
|
||||
transform: {
|
||||
"\\.[jt]sx?$": ["ts-jest", { useESM: true }],
|
||||
},
|
||||
|
||||
moduleNameMapper: {
|
||||
"(.+)\\.js": "$1",
|
||||
},
|
||||
extensionsToTreatAsEsm: [".ts"],
|
||||
preset: "ts-jest/presets/default-esm",
|
||||
testTimeout: 10000,
|
||||
testEnvironment: "node",
|
||||
globals: {
|
||||
__dirname: path.dirname(fileURLToPath(import.meta.url)),
|
||||
__filename: path.resolve(fileURLToPath(import.meta.url)),
|
||||
},
|
||||
};
|
||||
14
packages/fetch/jest.globals.d.ts
vendored
14
packages/fetch/jest.globals.d.ts
vendored
|
|
@ -1,14 +0,0 @@
|
|||
// This file declares the Jest globals for TypeScript
|
||||
import "@jest/globals";
|
||||
|
||||
declare global {
|
||||
const describe: typeof import("@jest/globals").describe;
|
||||
const expect: typeof import("@jest/globals").expect;
|
||||
const it: typeof import("@jest/globals").it;
|
||||
const test: typeof import("@jest/globals").test;
|
||||
const beforeAll: typeof import("@jest/globals").beforeAll;
|
||||
const afterAll: typeof import("@jest/globals").afterAll;
|
||||
const beforeEach: typeof import("@jest/globals").beforeEach;
|
||||
const afterEach: typeof import("@jest/globals").afterEach;
|
||||
const jest: typeof import("@jest/globals").jest;
|
||||
}
|
||||
4493
packages/fetch/package-lock.json
generated
4493
packages/fetch/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,7 @@
|
|||
"types": "dist/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
||||
"test": "vitest run",
|
||||
"build": "tsc"
|
||||
},
|
||||
"author": "Nate Sesti and Ty Dunn",
|
||||
|
|
@ -20,10 +20,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/follow-redirects": "^1.14.4",
|
||||
"@types/jest": "^29.5.14",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.3.4",
|
||||
"ts-node": "^10.9.2"
|
||||
"vitest": "^3.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { globalAgent } from "https";
|
|||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { afterEach, beforeEach, expect, test } from "vitest";
|
||||
import { getAgentOptions } from "./getAgentOptions.js";
|
||||
|
||||
// Store original env
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Readable } from "stream";
|
||||
import { describe, expect, it, test } from "vitest";
|
||||
import { parseDataLine, streamSse } from "./stream.js";
|
||||
|
||||
function createMockResponse(sseLines: string[]): Response {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { jest } from "@jest/globals";
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import { getProxyFromEnv, shouldBypassProxy } from "./util.js";
|
||||
|
||||
// Reset environment variables after each test
|
||||
afterEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@
|
|||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmitOnError": false,
|
||||
"types": ["node", "jest"],
|
||||
"types": ["node"],
|
||||
"outDir": "dist",
|
||||
"declaration": true
|
||||
// "sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*", "jest.globals.d.ts"]
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
|
|
|||
17
packages/fetch/vitest.config.ts
Normal file
17
packages/fetch/vitest.config.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
timeout: 10000,
|
||||
globals: true,
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// Handle .js imports for TypeScript files
|
||||
'./getAgentOptions.js': './getAgentOptions.ts',
|
||||
'./stream.js': './stream.ts',
|
||||
'./util.js': './util.ts',
|
||||
},
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue