Skip to content

Commit

Permalink
test: mock nvmrc file
Browse files Browse the repository at this point in the history
  • Loading branch information
tagoro9 committed Dec 15, 2023
1 parent 0531868 commit e9586a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { jest } from "@jest/globals"

import { runAction, Mute, runJS, ignoreInstalled } from "./testutil"
import fs from "fs"

Mute.all()

Expand All @@ -17,10 +18,19 @@ describe("skipping slow tests", () => {
})

describe("run", () => {
afterEach(() => {
jest.resetAllMocks()
jest.clearAllMocks()
jest.restoreAllMocks()
})

it("skips all tools if INPUT env empty", async () => {
// this runJS is just a sanity check for invoking the subprocess
// directly without using Tool.subprocess
return runJS("index", {}).then((proc) => {
// We have a .node-version file in the repo, so lets ignore it for the tests
const exists = jest.fn().mockImplementation(() => false)
jest.spyOn(fs, "existsSync").mockImplementation(exists)
expect(proc.stderr.toString()).toBe("")
expect(proc.stdout).toMatch(/go.*skipping/)
expect(proc.stdout).toMatch(/java.*skipping/)
Expand Down

0 comments on commit e9586a4

Please sign in to comment.