Skip to content

Testing Inputs

The create-testers package will include testing utilities that provide mock data to an input under test.

For example, testing the previous inputJSONFile:

import { createMockInputContext } from "create-testers";
import { inputJSONFile } from "./inputJSONFile";
describe("inputJSONFile", () => {
it("returns package data when the file on disk contains valid JSON", () => {
const expected = { name: "mock-package" };
const context = createMockInputContext({
files: {
"package.json": JSON.stringify(expected),
},
options: {
fileName: "package.json",
},
});
const actual = await inputJSONFile(context);
expect(actual).toEqual(expected);
});
});