Skip to content

Commit

Permalink
Fix jest extension (swc-project#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Sep 24, 2020
1 parent ab8df21 commit 1f00d9b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ecmascript/ext-transforms/src/jest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Jest {
computed: false, ..
},
) => match &callee.obj {
ExprOrSuper::Super(_) => {}
ExprOrSuper::Super(_) => new.push(T::from_stmt(stmt)),
ExprOrSuper::Expr(callee_obj) => match &**callee_obj {
Expr::Ident(i) if i.sym == *"jest" => match &*callee.prop {
Expr::Ident(prop) if HOIST_METHODS.contains(&*prop.sym) => {
Expand Down
27 changes: 27 additions & 0 deletions node-swc/__tests__/transform/hidden_jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,30 @@ it("should hoist methods", () => {
console.log(\"Hello\");
console.log(\"World\");`);
});


it("should preserve calls", () => {
const src = `class Foo {
method() {
super.foo()
}
}`;

expect(
swc.transformSync(src, {
jsc: {
transform: {
hidden: {
jest: true
}
},
target: 'es2019'
}
})
.code.trim()
).toBe(`class Foo {
method() {
super.foo();
}
}`);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.33",
"version": "1.2.34",
"description": "Super-fast alternative for babel",
"homepage": "https://swc.rs",
"main": "./index.js",
Expand Down
2 changes: 1 addition & 1 deletion wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "wasm"
repository = "https://github.com/swc-project/swc.git"
version = "1.2.32"
version = "1.2.34"

[lib]
crate-type = ["cdylib"]
Expand Down

0 comments on commit 1f00d9b

Please sign in to comment.