mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- partial fix for unittests
This commit is contained in:
parent
1f95797a60
commit
966ba74236
@ -1,7 +1,7 @@
|
||||
import { jest, test, expect } from "@jest/globals";
|
||||
|
||||
import { makeContext } from "./fixtures/context";
|
||||
import { RollupContext } from "../src/context";
|
||||
import { RollupContext, VerbosityLevel } from "../src/context";
|
||||
|
||||
(global as any).console = {
|
||||
warn: jest.fn(),
|
||||
@ -11,7 +11,7 @@ import { RollupContext } from "../src/context";
|
||||
|
||||
test("RollupContext", () => {
|
||||
const innerContext = makeContext();
|
||||
const context = new RollupContext(5, false, innerContext);
|
||||
const context = new RollupContext(VerbosityLevel.Debug + 1, false, innerContext);
|
||||
|
||||
context.warn("test");
|
||||
expect(innerContext.warn).toHaveBeenLastCalledWith("test");
|
||||
@ -52,7 +52,7 @@ test("RollupContext with 0 verbosity", () => {
|
||||
|
||||
test("RollupContext.error + debug negative verbosity", () => {
|
||||
const innerContext = makeContext();
|
||||
const context = new RollupContext(-100, true, innerContext);
|
||||
const context = new RollupContext(VerbosityLevel.Error - 1, true, innerContext);
|
||||
|
||||
context.error("verbosity is too low here");
|
||||
expect(innerContext.error).not.toBeCalled();
|
||||
@ -62,7 +62,7 @@ test("RollupContext.error + debug negative verbosity", () => {
|
||||
|
||||
test("RollupContext.error with bail", () => {
|
||||
const innerContext = makeContext();
|
||||
const context = new RollupContext(5, true, innerContext);
|
||||
const context = new RollupContext(VerbosityLevel.Debug, true, innerContext);
|
||||
|
||||
context.error("bail");
|
||||
expect(innerContext.error).toHaveBeenLastCalledWith("bail");
|
||||
|
||||
@ -35,16 +35,6 @@ export async function genBundle (inputArgs: Params) {
|
||||
const bundle = await rollup(createInput(inputArgs));
|
||||
const esm = await bundle.generate(createOutput(inputArgs.testDir));
|
||||
|
||||
// Rollup has some deprecated properties like `get isAsset`, so enumerating them with, e.g. `.toEqual`, causes a bunch of warnings to be output
|
||||
// delete the `isAsset` property for (much) cleaner logs
|
||||
const { output: files } = esm;
|
||||
for (const file of files) {
|
||||
if ("isAsset" in file) {
|
||||
const optIsAsset = file as Partial<Pick<OutputAsset, "isAsset">> & Omit<OutputAsset, "isAsset">;
|
||||
delete optIsAsset["isAsset"];
|
||||
}
|
||||
}
|
||||
|
||||
return esm;
|
||||
}
|
||||
|
||||
|
||||
@ -3,16 +3,18 @@ const pkg = require("./package.json");
|
||||
/** @type {import("ts-jest").InitialOptionsTsJest} */
|
||||
const config = {
|
||||
// ts-jest settings
|
||||
preset: "ts-jest",
|
||||
preset: "ts-jest/presets/js-with-ts",
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
tsconfig: "./tsconfig.test.json",
|
||||
},
|
||||
// other globals (unrelated to ts-jest) -- these are namespaced so they don't conflict with anything else
|
||||
"rpt2__TS_VERSION_RANGE": pkg.peerDependencies.typescript,
|
||||
"rpt2__ROLLUP_VERSION_RANGE": pkg.peerDependencies.rollup,
|
||||
"rpt2__RPT2_VERSION": pkg.version,
|
||||
},
|
||||
transform: {
|
||||
"<rootdir>/__tests__/*.ts": ["ts-jest", {
|
||||
tsconfig: "./tsconfig.test.json",
|
||||
}],
|
||||
},
|
||||
|
||||
// jest settings
|
||||
injectGlobals: false, // use @jest/globals instead
|
||||
@ -23,6 +25,7 @@ const config = {
|
||||
"node_modules", // default
|
||||
"<rootDir>/__tests__/" // ignore any test helper files
|
||||
],
|
||||
moduleDirectories: ["node_modules", "<rootdir>/src/"],
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
|
||||
7894
package-lock.json
generated
7894
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@
|
||||
"@jest/globals": "^28.0.3",
|
||||
"@rollup/plugin-commonjs": "^25.0.0",
|
||||
"@rollup/plugin-node-resolve": "15.0.2",
|
||||
"@types/find-cache-dir": "^2.0.0",
|
||||
"@types/find-cache-dir": "^3.2.1",
|
||||
"@types/fs-extra": "8.0.1",
|
||||
"@types/graphlib": "2.1.7",
|
||||
"@types/jest": "^27.5.0",
|
||||
@ -56,14 +56,14 @@
|
||||
"@types/semver": "7.3.12",
|
||||
"colors": "1.4.0",
|
||||
"graphlib": "2.1.8",
|
||||
"jest": "^28.0.0",
|
||||
"jest": "^29.5.0",
|
||||
"lodash": "4.17.21",
|
||||
"object-hash": "3.0.0",
|
||||
"rimraf": "3.0.2",
|
||||
"rollup": "^3.22.0",
|
||||
"rollup-plugin-re": "1.0.7",
|
||||
"rollup-plugin-typescript2": "0.34.1",
|
||||
"ts-jest": "^28.0.0",
|
||||
"ts-jest": "^29.1.0",
|
||||
"tslint": "6.1.3",
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user