Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin e2e tests bug #9141

Closed
khalilou88 opened this issue Feb 28, 2022 · 6 comments
Closed

Plugin e2e tests bug #9141

khalilou88 opened this issue Feb 28, 2022 · 6 comments

Comments

@khalilou88
Copy link
Contributor

khalilou88 commented Feb 28, 2022

Current Behavior

E2e tests fails

Expected Behavior

E2e tests should work properly

Steps to Reproduce

  1. npx create-nx-plugin plugin-e2e --pluginName my-plugin
  2. Add plugin to nx.json under tmp/nx-e2e/proj
it('should create my-plugin', async () => {
  const plugin = uniq('my-plugin');
  ensureNxProject('@plugin-e2e/my-plugin', 'dist/packages/my-plugin');

  let nxJson = readJson('nx.json');
  nxJson.plugins = ['@plugin-e2e/my-plugin'];
  updateFile('nx.json', JSON.stringify(nxJson));
  
  await runNxCommandAsync(
    `generate @plugin-e2e/my-plugin:my-plugin ${plugin}`
  );

  const result = await runNxCommandAsync(`build ${plugin}`);
  expect(result.stdout).toContain('Executor ran');
}, 120000);
  1. Run e2e tests
    nx e2e my-plugin-e2e --skip-nx-cache

the error is in this fuction

function findPluginPackageJson(path, plugin) {
    while (true) {
        if (!path.startsWith(app_root_1.appRootPath)) {
            throw new Error("Couldn't find a package.json for Nx plugin:" + plugin);
        }
        if ((0, fs_1.existsSync)((0, path_1.join)(path, 'package.json'))) {
            return (0, path_1.join)(path, 'package.json');
        }
        path = (0, path_1.dirname)(path);
    }
}

this condition if (!path.startsWith(app_root_1.appRootPath)) not work in this case because the plugin is not inside the e2e workspace but inside dist folder of the root workspace

Failure Logs

[NX Daemon Server] - 2022-02-28T10:56:43.512Z - Error detected when creating a project graph: Couldn't find a package.json for Nx plugin:@plugin-e2e/my-plugin
[NX Daemon Server] - 2022-02-28T10:56:43.512Z - [REQUEST]: Responding to the client with an error. Error when preparing serialized project graph. Couldn't find a package.json for Nx plugin:@plugin-e2e/my-plugin
Error: Couldn't find a package.json for Nx plugin:@plugin-e2e/my-plugin
    at findPluginPackageJson (D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\@nrwl\tao\src\shared\nx-plugin.js:12:19)
    at D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\@nrwl\tao\src\shared\nx-plugin.js:28:64
    at Array.map (<anonymous>)
    at loadNxPlugins (D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\@nrwl\tao\src\shared\nx-plugin.js:24:38)
    at D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\@nrwl\workspace\src\core\project-graph\build-nodes\workspace-projects.js:17:119
    at Array.forEach (<anonymous>)
    at buildWorkspaceProjectNodes (D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\@nrwl\workspace\src\core\project-graph\build-nodes\workspace-projects.js:11:41)
    at D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\@nrwl\workspace\src\core\project-graph\build-project-graph.js:73:54
    at Generator.next (<anonymous>)
    at D:\Workspace\Projects\plugin-e2e\tmp\nx-e2e\proj\node_modules\tslib\tslib.js:117:75

Environment

nx report

NX Report complete - copy this into the issue template

Node : 16.14.0
OS : win32 x64
npm : 8.3.1

nx : 13.8.3
@nrwl/angular : undefined
@nrwl/cli : 13.8.3
@nrwl/cypress : undefined
@nrwl/detox : undefined
@nrwl/devkit : 13.8.3
@nrwl/eslint-plugin-nx : 13.8.3
@nrwl/express : undefined
@nrwl/jest : 13.8.3
@nrwl/js : undefined
@nrwl/linter : 13.8.3
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : 13.8.3
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : undefined
@nrwl/tao : 13.8.3
@nrwl/web : undefined
@nrwl/workspace : 13.8.3
typescript : 4.5.5
rxjs : 6.6.7

Community plugins:
@nrwl/nx-plugin: 13.8.3

(node:25856) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at D:\Workspace\Projects\plugin-e2e\node_modules\tslib\package.json.
Update this package.json to use a subpath pattern like "./*".
(Use node --trace-deprecation ... to show where the warning was created)

@khalilou88
Copy link
Contributor Author

check this repo for reproduction https://github.com/khalilou88/plugin-e2e

@AgentEnder
Copy link
Member

Hey @khalilou88! I think this will be fixed by the changes in #9116.

@AgentEnder AgentEnder added the blocked: retry with latest Retry with latest release or head. label Mar 25, 2022
@AgentEnder
Copy link
Member

They local plugins stuff is available in nx@next, can you test it out and see if it still fails?

@github-actions
Copy link

github-actions bot commented Apr 9, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Apr 9, 2022
@khalilou88
Copy link
Contributor Author

@AgentEnder Just made a test with the version 13.10.3 and it's working fine. Thank you.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants