programWithTestStub.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var programWithTestStub_exports = {};
  20. __export(programWithTestStub_exports, {
  21. program: () => import_program2.program
  22. });
  23. module.exports = __toCommonJS(programWithTestStub_exports);
  24. var import_processLauncher = require("../server/utils/processLauncher");
  25. var import_utils = require("../utils");
  26. var import_program = require("./program");
  27. var import_program2 = require("./program");
  28. function printPlaywrightTestError(command) {
  29. const packages = [];
  30. for (const pkg of ["playwright", "playwright-chromium", "playwright-firefox", "playwright-webkit"]) {
  31. try {
  32. require.resolve(pkg);
  33. packages.push(pkg);
  34. } catch (e) {
  35. }
  36. }
  37. if (!packages.length)
  38. packages.push("playwright");
  39. const packageManager = (0, import_utils.getPackageManager)();
  40. if (packageManager === "yarn") {
  41. console.error(`Please install @playwright/test package before running "yarn playwright ${command}"`);
  42. console.error(` yarn remove ${packages.join(" ")}`);
  43. console.error(" yarn add -D @playwright/test");
  44. } else if (packageManager === "pnpm") {
  45. console.error(`Please install @playwright/test package before running "pnpm exec playwright ${command}"`);
  46. console.error(` pnpm remove ${packages.join(" ")}`);
  47. console.error(" pnpm add -D @playwright/test");
  48. } else {
  49. console.error(`Please install @playwright/test package before running "npx playwright ${command}"`);
  50. console.error(` npm uninstall ${packages.join(" ")}`);
  51. console.error(" npm install -D @playwright/test");
  52. }
  53. }
  54. const kExternalPlaywrightTestCommands = [
  55. ["test", "Run tests with Playwright Test."],
  56. ["show-report", "Show Playwright Test HTML report."],
  57. ["merge-reports", "Merge Playwright Test Blob reports"]
  58. ];
  59. function addExternalPlaywrightTestCommands() {
  60. for (const [command, description] of kExternalPlaywrightTestCommands) {
  61. const playwrightTest = import_program.program.command(command).allowUnknownOption(true).allowExcessArguments(true);
  62. playwrightTest.description(`${description} Available in @playwright/test package.`);
  63. playwrightTest.action(async () => {
  64. printPlaywrightTestError(command);
  65. (0, import_processLauncher.gracefullyProcessExitDoNotHang)(1);
  66. });
  67. }
  68. }
  69. if (!process.env.PW_LANG_NAME)
  70. addExternalPlaywrightTestCommands();
  71. // Annotate the CommonJS export names for ESM import in node:
  72. 0 && (module.exports = {
  73. program
  74. });