Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests to assert rewiremock compatibility #799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"require-inject": "^1.4.4",
"requizzle": "^0.2.1",
"rewire": "^4.0.1",
"rewiremock": "^3.13.6",
"semver": "^5.7.0",
"sinon": "^7.3.2",
"sleep": "^5.2.4",
Expand Down
4 changes: 4 additions & 0 deletions test/fixture/scenario/rewiremock/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { extname } from "path"
import b from "./b.js"

export default () => "a" + b + extname("")
1 change: 1 addition & 0 deletions test/fixture/scenario/rewiremock/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty module.
3 changes: 3 additions & 0 deletions test/fixture/scenario/rewiremock/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import a from "./a.js"

export default () => a()
22 changes: 22 additions & 0 deletions test/fixture/scenario/rewiremock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import assert from "assert"
import rewiremock from "rewiremock"

const a = rewiremock
.proxy("./a.js", {
path: {
extname: () => "c"
},
"./b.js": "b"
})

assert.strictEqual(a.default(), "abc")

const c = rewiremock.proxy("./c.js", {
path: {
extname: () => "b"
},
"./b.js": "c"
})

assert.strictEqual(c.default(), "acb")

8 changes: 7 additions & 1 deletion test/scenario-tests.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SemVer from "semver"

import assert from "assert"
import execa from "execa"
import fs from "fs-extra"
Expand Down Expand Up @@ -185,6 +184,13 @@ describe("scenario tests", function () {
], envAuto)
)

it("should work with rewiremock", () => {
node([
"-r", pkgPath,
path.resolve("fixture/scenario/rewiremock")
], envAuto)
})

it("should work with sinon", () =>
node([
path.resolve("fixture/scenario/sinon")
Expand Down