Skip to content

Commit fc4bb7f

Browse files
authored
Merge pull request #303 from plopjs/update-testing-dep
chore: update testing dep
2 parents 5214d44 + c85af29 commit fc4bb7f

File tree

7 files changed

+128
-18
lines changed

7 files changed

+128
-18
lines changed

package-lock.json

Lines changed: 108 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"dependencies": {
4949
"@types/liftoff": "^4.0.0",
5050
"chalk": "^5.0.0",
51-
"cli-testing-library": "^1.0.0-alpha.10",
51+
"cli-testing-library": "^1.0.0-alpha.14",
5252
"interpret": "^2.2.0",
5353
"liftoff": "^4.0.0",
5454
"minimist": "^1.2.5",

tests/action-failure.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import { fileURLToPath } from "node:url";
77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

99
test("should exit with code 1 when failed actions", async () => {
10-
const result = await renderPlop([], {
10+
const { findByText, userEvent } = await renderPlop([], {
1111
cwd: resolve(__dirname, "./examples/action-failure"),
1212
});
13-
const { findByText, userEvent } = result;
14-
expect(await findByText("What is your name?")).toBeTruthy();
13+
expect(await findByText("What is your name?")).toBeInTheConsole();
1514
userEvent.keyboard("Joe");
16-
expect(await findByText("Joe")).toBeTruthy();
15+
expect(await findByText("Joe")).toBeInTheConsole();
1716
userEvent.keyboard("[Enter]");
1817
const actionOutput = await findByText("Action failed");
1918
await waitFor(() =>

tests/config/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export default {
1010
testMatch: ["**/tests/**.spec.js"],
1111
snapshotSerializers: ["jest-snapshot-serializer-ansi"],
1212
transform: {},
13+
setupFilesAfterEnv: [join(__dirname, "./jest.setup.js")],
1314
};

tests/config/jest.setup.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// require("cli-testing-library/extend-expect");
2+
3+
import { configure } from "cli-testing-library";
4+
import "cli-testing-library/extend-expect";
5+
6+
configure({
7+
asyncUtilTimeout: 2000,
8+
renderAwaitTime: 1000,
9+
errorDebounceTimeout: 1000,
10+
});

tests/input-processing.spec.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import { fileURLToPath } from "node:url";
55
const __dirname = dirname(fileURLToPath(import.meta.url));
66

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

1412
test("should show help information on help flag", async () => {
1513
const { findByText } = await renderPlop(["--help"]);
16-
const { stdoutStr } = await findByText("Usage:");
17-
expect(stdoutStr).toMatchSnapshot();
14+
const { stdoutArr } = await findByText("Usage:");
15+
expect(stdoutArr.join("\n")).toMatchSnapshot();
1816
});
1917

2018
test("should show version on version flag", async () => {

tests/render.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1212
export function renderScript(script, args = [], opts = {}) {
1313
const { cwd = __dirname } = opts;
1414

15-
const rendered = render(
15+
return render(
1616
resolve(__dirname, "../node_modules/.bin/nyc"),
1717
["--silent", "node", script, ...args],
1818
{
@@ -22,8 +22,6 @@ export function renderScript(script, args = [], opts = {}) {
2222
},
2323
}
2424
);
25-
26-
return rendered;
2725
}
2826

2927
/**

0 commit comments

Comments
 (0)