Skip to content

Commit

Permalink
Disable override tests on > npm 7
Browse files Browse the repository at this point in the history
It looks like npm config overrides stopped working in npm 7. Let's just disable those tests when running in envs that doesn't support it. It will continue working if you are running npm 6, but you should stop doing that.

Closes #79
  • Loading branch information
bcomnes committed Jun 10, 2022
1 parent 9a64a46 commit 01c4a43
Showing 1 changed file with 71 additions and 64 deletions.
135 changes: 71 additions & 64 deletions test/package-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// Requirements
//------------------------------------------------------------------------------

const { execSync } = require("child_process")
const assert = require("assert").strict
const nodeApi = require("../lib")
const util = require("./lib/util")
Expand All @@ -28,81 +29,87 @@ describe("[package-config] it should have an ability to overwrite package's conf

beforeEach(removeResult)

it("Node API should address \"packageConfig\" option", async () => {
await nodeApi("test-task:package-config", { packageConfig: { "npm-run-all-test": { test: "OVERWRITTEN" } } })
assert(result() === "OVERWRITTEN")
})
const [major] = execSync("npm --version", { encoding: "utf8" }).trim().split(".")

it("Node API should address \"packageConfig\" option for multiple variables", async () => {
await nodeApi("test-task:package-config2", { packageConfig: { "npm-run-all-test": { test: "1", test2: "2", test3: "3" } } })
assert(result() === "1\n2\n3")
})
const supportsOverrides = major <= 6

describe("CLI commands should address \"--a:b=c\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
if (supportsOverrides) {
it("Node API should address \"packageConfig\" option", async () => {
await nodeApi("test-task:package-config", { packageConfig: { "npm-run-all-test": { test: "OVERWRITTEN" } } })
assert.equal(result(), "OVERWRITTEN")
})

it("run-s command", async () => {
await runSeq(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
it("Node API should address \"packageConfig\" option for multiple variables", async () => {
await nodeApi("test-task:package-config2", { packageConfig: { "npm-run-all-test": { test: "1", test2: "2", test3: "3" } } })
assert.equal(result(), "1\n2\n3")
})

it("run-p command", async () => {
await runPar(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
describe("CLI commands should address \"--a:b=c\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})

it("run-s command", async () => {
await runSeq(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})

it("run-p command", async () => {
await runPar(["test-task:package-config", "--npm-run-all-test:test=OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})
})
})

describe("CLI commands should address \"--a:b=c\" style options for multiple variables", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert(result() === "1\n2\n3")
describe("CLI commands should address \"--a:b=c\" style options for multiple variables", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert.equal(result(), "1\n2\n3")
})

it("run-s command", async () => {
await runSeq(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert.equal(result(), "1\n2\n3")
})

it("run-p command", async () => {
await runPar(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert.equal(result(), "1\n2\n3")
})
})

it("run-s command", async () => {
await runSeq(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert(result() === "1\n2\n3")
describe("CLI commands should address \"--a:b c\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})

it("run-s command", async () => {
await runSeq(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})

it("run-p command", async () => {
await runPar(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})
})

it("run-p command", async () => {
await runPar(["test-task:package-config2", "--npm-run-all-test:test=1", "--npm-run-all-test:test2=2", "--npm-run-all-test:test3=3"])
assert(result() === "1\n2\n3")
describe("CLI commands should transfar overriting nested commands.", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})

it("run-s command", async () => {
await runSeq(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})

it("run-p command", async () => {
await runPar(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert.equal(result(), "OVERWRITTEN")
})
})
})

describe("CLI commands should address \"--a:b c\" style options", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})

it("run-s command", async () => {
await runSeq(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})

it("run-p command", async () => {
await runPar(["test-task:package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
})

describe("CLI commands should transfar overriting nested commands.", () => {
it("npm-run-all command", async () => {
await runAll(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})

it("run-s command", async () => {
await runSeq(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})

it("run-p command", async () => {
await runPar(["test-task:nested-package-config", "--npm-run-all-test:test", "OVERWRITTEN"])
assert(result() === "OVERWRITTEN")
})
})
}
})

0 comments on commit 01c4a43

Please sign in to comment.