Skip to content

Commit

Permalink
Merge pull request #303 from plopjs/update-testing-dep
Browse files Browse the repository at this point in the history
chore: update testing dep
  • Loading branch information
crutchcorn authored Dec 13, 2021
2 parents 5214d44 + c85af29 commit fc4bb7f
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 18 deletions.
112 changes: 108 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"@types/liftoff": "^4.0.0",
"chalk": "^5.0.0",
"cli-testing-library": "^1.0.0-alpha.10",
"cli-testing-library": "^1.0.0-alpha.14",
"interpret": "^2.2.0",
"liftoff": "^4.0.0",
"minimist": "^1.2.5",
Expand Down
7 changes: 3 additions & 4 deletions tests/action-failure.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));

test("should exit with code 1 when failed actions", async () => {
const result = await renderPlop([], {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/action-failure"),
});
const { findByText, userEvent } = result;
expect(await findByText("What is your name?")).toBeTruthy();
expect(await findByText("What is your name?")).toBeInTheConsole();
userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeTruthy();
expect(await findByText("Joe")).toBeInTheConsole();
userEvent.keyboard("[Enter]");
const actionOutput = await findByText("Action failed");
await waitFor(() =>
Expand Down
1 change: 1 addition & 0 deletions tests/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export default {
testMatch: ["**/tests/**.spec.js"],
snapshotSerializers: ["jest-snapshot-serializer-ansi"],
transform: {},
setupFilesAfterEnv: [join(__dirname, "./jest.setup.js")],
};
10 changes: 10 additions & 0 deletions tests/config/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// require("cli-testing-library/extend-expect");

import { configure } from "cli-testing-library";
import "cli-testing-library/extend-expect";

configure({
asyncUtilTimeout: 2000,
renderAwaitTime: 1000,
errorDebounceTimeout: 1000,
});
10 changes: 4 additions & 6 deletions tests/input-processing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));

test("should report a missing plopfile when not copied", async () => {
await expect(() => renderPlop()).rejects.toMatchInlineSnapshot(
/\[PLOP\] No plopfile found/,
`Object {}`
);
const { findByError } = await renderPlop();
expect(await findByError(/\[PLOP\] No plopfile found/)).toBeInTheConsole();
});

test("should show help information on help flag", async () => {
const { findByText } = await renderPlop(["--help"]);
const { stdoutStr } = await findByText("Usage:");
expect(stdoutStr).toMatchSnapshot();
const { stdoutArr } = await findByText("Usage:");
expect(stdoutArr.join("\n")).toMatchSnapshot();
});

test("should show version on version flag", async () => {
Expand Down
4 changes: 1 addition & 3 deletions tests/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
export function renderScript(script, args = [], opts = {}) {
const { cwd = __dirname } = opts;

const rendered = render(
return render(
resolve(__dirname, "../node_modules/.bin/nyc"),
["--silent", "node", script, ...args],
{
Expand All @@ -22,8 +22,6 @@ export function renderScript(script, args = [], opts = {}) {
},
}
);

return rendered;
}

/**
Expand Down

0 comments on commit fc4bb7f

Please sign in to comment.