版博士V2.0程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

action-failure.spec.js 768 B

123456789101112131415161718192021
  1. import { resolve, dirname } from "node:path";
  2. import { waitFor } from "cli-testing-library";
  3. import { renderPlop } from "./render.js";
  4. import { fileURLToPath } from "node:url";
  5. const __dirname = dirname(fileURLToPath(import.meta.url));
  6. test("should exit with code 1 when failed actions", async () => {
  7. const { findByText, userEvent } = await renderPlop([], {
  8. cwd: resolve(__dirname, "./examples/action-failure"),
  9. });
  10. expect(await findByText("What is your name?")).toBeInTheConsole();
  11. userEvent.keyboard("Joe");
  12. expect(await findByText("Joe")).toBeInTheConsole();
  13. userEvent.keyboard("[Enter]");
  14. const actionOutput = await findByText("Action failed");
  15. await waitFor(() =>
  16. expect(actionOutput.hasExit()).toStrictEqual({ exitCode: 1 })
  17. );
  18. });