@swc/plugin-jest 7.0.3 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +12 -0
- package/package.json +1 -1
- package/swc_plugin_jest.wasm +0 -0
- package/Cargo.toml +0 -26
- package/__tests__/wasm.test.ts +0 -95
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
package/swc_plugin_jest.wasm
CHANGED
|
Binary file
|
package/Cargo.toml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
authors = { workspace = true }
|
|
3
|
-
description = "Jest plugin for https://swc.rs"
|
|
4
|
-
edition = { workspace = true }
|
|
5
|
-
homepage = { workspace = true }
|
|
6
|
-
license = { workspace = true }
|
|
7
|
-
name = "swc_plugin_jest"
|
|
8
|
-
publish = false
|
|
9
|
-
repository = { workspace = true }
|
|
10
|
-
rust-version = { workspace = true }
|
|
11
|
-
version = "0.31.4"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[lib]
|
|
15
|
-
crate-type = ["cdylib", "rlib"]
|
|
16
|
-
|
|
17
|
-
[dependencies]
|
|
18
|
-
phf = { workspace = true, features = ["macros"] }
|
|
19
|
-
serde = { workspace = true, features = ["derive"] }
|
|
20
|
-
swc_common = { workspace = true, features = ["concurrent"] }
|
|
21
|
-
swc_core = { workspace = true, features = ["ecma_plugin_transform"] }
|
|
22
|
-
swc_ecma_ast = { workspace = true }
|
|
23
|
-
swc_ecma_utils = { workspace = true }
|
|
24
|
-
swc_ecma_visit = { workspace = true }
|
|
25
|
-
swc_plugin_macro = { workspace = true }
|
|
26
|
-
tracing = { workspace = true, features = ["release_max_level_off"] }
|
package/__tests__/wasm.test.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { transform, type Options } from "@swc/core";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import url from "node:url";
|
|
5
|
-
|
|
6
|
-
const options: Options = {
|
|
7
|
-
jsc: {
|
|
8
|
-
parser: {
|
|
9
|
-
syntax: "ecmascript",
|
|
10
|
-
jsx: true,
|
|
11
|
-
},
|
|
12
|
-
experimental: {
|
|
13
|
-
plugins: [
|
|
14
|
-
[
|
|
15
|
-
path.join(
|
|
16
|
-
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
17
|
-
"..",
|
|
18
|
-
"swc_plugin_jest.wasm",
|
|
19
|
-
),
|
|
20
|
-
{},
|
|
21
|
-
],
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
describe("jest swc plugin", () => {
|
|
28
|
-
it("should hoist jest.mock calls", async () => {
|
|
29
|
-
const input = `
|
|
30
|
-
console.log('before mock');
|
|
31
|
-
jest.mock('./some-module');
|
|
32
|
-
console.log('after mock');
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const output = await transform(input, options);
|
|
36
|
-
|
|
37
|
-
// Remove whitespace and newlines for comparison
|
|
38
|
-
const normalizedOutput = output.code.replace(/\s+/g, "");
|
|
39
|
-
const expectedOutput = `
|
|
40
|
-
jest.mock('./some-module');
|
|
41
|
-
console.log('before mock');
|
|
42
|
-
console.log('after mock');
|
|
43
|
-
`.replace(/\s+/g, "");
|
|
44
|
-
|
|
45
|
-
expect(normalizedOutput).toBe(expectedOutput);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("should hoist multiple jest method calls", async () => {
|
|
49
|
-
const input = `
|
|
50
|
-
console.log('start');
|
|
51
|
-
jest.unmock('./module-a');
|
|
52
|
-
var something = true;
|
|
53
|
-
jest.mock('./module-b');
|
|
54
|
-
jest.enableAutomock();
|
|
55
|
-
console.log('end');
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
const output = await transform(input, options);
|
|
59
|
-
|
|
60
|
-
// Remove whitespace and newlines for comparison
|
|
61
|
-
const normalizedOutput = output.code.replace(/\s+/g, "");
|
|
62
|
-
const expectedOutput = `
|
|
63
|
-
jest.unmock('./module-a');
|
|
64
|
-
jest.mock('./module-b');
|
|
65
|
-
jest.enableAutomock();
|
|
66
|
-
console.log('start');
|
|
67
|
-
var something = true;
|
|
68
|
-
console.log('end');
|
|
69
|
-
`.replace(/\s+/g, "");
|
|
70
|
-
|
|
71
|
-
expect(normalizedOutput).toBe(expectedOutput);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("should not hoist non-hoistable jest methods", async () => {
|
|
75
|
-
const input = `
|
|
76
|
-
console.log('start');
|
|
77
|
-
jest.spyOn(something, 'method');
|
|
78
|
-
jest.mock('./module');
|
|
79
|
-
console.log('end');
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
const output = await transform(input, options);
|
|
83
|
-
|
|
84
|
-
// Remove whitespace and newlines for comparison
|
|
85
|
-
const normalizedOutput = output.code.replace(/\s+/g, "");
|
|
86
|
-
const expectedOutput = `
|
|
87
|
-
jest.mock('./module');
|
|
88
|
-
console.log('start');
|
|
89
|
-
jest.spyOn(something, 'method');
|
|
90
|
-
console.log('end');
|
|
91
|
-
`.replace(/\s+/g, "");
|
|
92
|
-
|
|
93
|
-
expect(normalizedOutput).toBe(expectedOutput);
|
|
94
|
-
});
|
|
95
|
-
});
|