1
0
mirror of synced 2025-12-19 18:11:23 -05:00
Files
blitz/packages/cli/test/commands/test.test.ts
Justin Hall b3814fc7c0 Standardize prettier options across all Blitz code bases (#703)
Co-authored-by: Brandon Bayer <b@bayer.ws> (meta)
2020-06-19 09:33:57 +07:00

56 lines
1.4 KiB
TypeScript

jest.mock("cross-spawn")
jest.mock("has-yarn")
import crossSpawn from "cross-spawn"
import hasYarn from "has-yarn"
import {Test} from "../../src/commands/test"
const testParams = [["test"], {stdio: "inherit"}]
const testWatchParams = [["test:watch"], {stdio: "inherit"}]
describe("Test command", () => {
beforeEach(() => {
jest.clearAllMocks()
})
it("runs yarn test script", async () => {
jest.spyOn(hasYarn, "default").mockReturnValue(true)
await Test.run([])
expect(crossSpawn.spawn).toBeCalledWith("yarn", ...testParams)
})
it("runs npm test script", async () => {
jest.spyOn(hasYarn, "default").mockReturnValue(false)
await Test.run([])
expect(crossSpawn.spawn).toBeCalledWith("npm", ...testParams)
})
it("runs yarn test:watch script", async () => {
jest.spyOn(hasYarn, "default").mockReturnValue(true)
await Test.run(["watch"])
expect(crossSpawn.spawn).toBeCalledWith("yarn", ...testWatchParams)
})
it("runs yarn test:watch script with alias", async () => {
jest.spyOn(hasYarn, "default").mockReturnValue(true)
await Test.run(["w"])
expect(crossSpawn.spawn).toBeCalledWith("yarn", ...testWatchParams)
})
it("runs yarn test and ignores invalid argument", async () => {
jest.spyOn(hasYarn, "default").mockReturnValue(true)
await Test.run(["invalid"])
expect(crossSpawn.spawn).toBeCalledWith("yarn", ...testParams)
})
})