nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.77k stars 2.37k forks source link

E2E test setup with verdaccio #19683

Open gitLinda opened 1 year ago

gitLinda commented 1 year ago

Current Behavior

When adding plugin e2e tests with the e2eProjectGenerator, a start-local-registry.ts is generated. When I run the e2e target of my-plugin-e2e, which executes the start-local-registry.ts script, I get the following error:

Jest: Got error running globalSetup - C:\Users\lkrue\develop\temp\jose\tools\scripts\start-local-registry.ts, reason: spawnSync C:\Users\lkrue\develop\temp\jose\node_modules\.pnpm\nx@16.10.0_@swc-node+register@1.6.8_@swc+core@1.3.93\node_modules\nx\bin\nx.js UNKNOWN

I checked the path in the node modules, and it's there. Also the const nx = require.resolve('nx') line is fine. The error happens when executing execFileSync( nx, ['run-many', '--targets', 'publish', '--ver', '1.0.0', '--tag', 'e2e'], { env: process.env, stdio: 'inherit' } );

It seems to be a windows problem. Since it is running fine on Mac.

Expected Behavior

The e2e tests can be executed

GitHub Repo

No response

Steps to Reproduce

  1. Generate a new plugin
  2. Generate a e2e app for the plugin
  3. Run the e2e target of the e2e app

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.14.0
   OS     : win32-x64
   pnpm   : 8.7.6

   nx                 : 16.10.0
   @nx/js             : 16.10.0
   @nrwl/js           : 15.9.2
   @nx/jest           : 16.10.0
   @nx/linter         : 16.10.0
   @nx/workspace      : 16.10.0
   @nrwl/workspace    : 15.9.2
   @nx/devkit         : 16.10.0
   @nrwl/devkit       : 15.9.2
   @nx/eslint-plugin  : 16.10.0
   @nx/plugin         : 16.10.0
   @nrwl/tao          : 15.9.2
   @nrwl/web          : 15.9.2
   typescript         : 5.1.6
   ---------------------------------------
   Local workspace plugins:
         @myorg/my-plugin
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/js@15.9.2
     - @nrwl/workspace@15.9.2
     - @nrwl/devkit@15.9.2
     - @nrwl/tao@15.9.2
     - @nrwl/web@15.9.2

   To fix this, run `nx migrate nx@16.10.0`

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

khalilou88 commented 1 year ago

Same error on windows: https://github.com/khalilou88/jnxplus/actions/runs/6727510978/job/18285417595

pogiaron commented 9 months ago

Let's consider these scripts:

log.js

#!/usr/bin/env node
console.log("log.js");

test.js

const { execFileSync  } = require('child_process');
const cmd = 'C:\\pathto\\log.js';  //on ubuntu '/pathto/log.js'
execFileSync(cmd, {stdio: 'inherit'});

if you run the test.js in Windows you will get this error: Error: spawnSync C:\pathto\log.js UNKNOWN

if you run the test.js on Unix-like platforms it will run You can read about the shebang-line here: https://stackoverflow.com/a/33510581

You can't run a js file like this with execFileSync in windows. For a workaround, I think this can be done

  execFileSync(
    nx,
    ['run-many', '--targets', 'publish', '--ver', '0.0.0-e2e', '--tag', 'e2e'],
    { env: process.env, stdio: 'inherit', shell: true }
  );

or

  execFile(
    `${nx} run-many --targets publish --ver 0.0.0-e2e --tag e2e`
  );

I think a wrapper batch script is missing.

github-actions[bot] commented 1 week ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏