Closed gnuechtel closed 2 years ago
Interesting! The daemon errors make sense, but the lack of an @
sign for the generated plugin is intriguing. This doesn't occur if you generate a second plugin, or were to generate the first plugin in an existing workspace.
Looks like the import path is set on that function, and we used to not obey it very well. Fixing that issue, caused the new error which is evidently not covered by a test. I'll look into the daemon stuff and get this pushed out.
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.
I started plugin development with Nx and end-to-end tests do not work out-of-the box.
There were two hurdles to jump over:
I will provide a solution/work-around here. But I think it should be included in the end-to-end test setup or project setup.
Furthermore, I believe the package name is not created as intended or I miss something by reading the documentation.
Steps to Reproduce
Initialize a new Nx plugins repository
We create a new plugin "my-plugin" with a new monorepo "my-org":
That works.
Invoke end-to-end-tests
Now we want to invoke the end-to-end tests for the just created plugin.
First try
Second try
So
npm install
failed in the end-to-end tests. Fortunately, we can investigate the createdtmp
directory:Now we search 'my-org/my-plugin' in repo's directory and replace it by '@my-org/my-plugin'.
The following files should be changed:
tsconfig.base.json
packages/my-plugin/package.json
packages/my-plugin/src/generators/my-plugin/generator.ts
e2e/my-plugin-e2e/tests/my-plugin.spec.ts
But only one test passes:
Third try (with solution)
So our second try failed, because of locked resources. The most common reason for locked resources are running processes. So our first suspect is Nx daemon, which fortunately reveals itself in task manager.
So the solution is to stop the Nx daemon.
First kill the processes:
Then set the env variable:
Now everything works fine:
Example repository (with fix of package names in the second commit): https://github.com/gnuechtel/nx-plugin-example
Environment