-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
test: run cli tests in top level npm test #825
Conversation
I am fine with this change as a short-term fix, but wouldn't it better to fix the layout of CLI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the CLI tests aren't following our monorepo layout, that tells me something fishy is going on...
@@ -39,7 +39,7 @@ | |||
"build:current": "lerna run --loglevel=silent build:current", | |||
"pretest": "npm run build:current", | |||
"test": "node packages/build/bin/run-nyc npm run mocha", | |||
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\"", | |||
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\" \"packages/cli/test\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there no dist folder for the CLI tests? It should follow the existing pattern in the current command (packages/cli/dist/test/**/*.js
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjdelisle I think the CLI cannot use TypeScript because it's a Yeoman generator under the hood, which has implications on the project layout. One more reason for getting rid of Yeoman! See #844
CLI is written in JS not TS! So there's no build for it, which means there is no |
@virkt25 Please check why CI fails. |
package.json
Outdated
@@ -37,7 +37,8 @@ | |||
"clean": "lerna run --loglevel=silent clean", | |||
"build": "lerna run --loglevel=silent build", | |||
"build:current": "lerna run --loglevel=silent build:current", | |||
"pretest": "npm run build:current", | |||
"pretest": "npm run build:current && npm run cli:link", | |||
"cli:link": "cd packages/cli && npm link", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with the cli:link
command, but not having it added to pretest
. This means that any time someone runs tests, they're going to lose their existing global installation of the CLI and have it replaced with the locally-linked one. I expect this would cause havoc for contributors down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the alteration to pretest, IMO.
package.json
Outdated
@@ -37,7 +37,8 @@ | |||
"clean": "lerna run --loglevel=silent clean", | |||
"build": "lerna run --loglevel=silent build", | |||
"build:current": "lerna run --loglevel=silent build:current", | |||
"pretest": "npm run build:current", | |||
"pretest": "npm run build:current && npm run cli:link", | |||
"cli:link": "cd packages/cli && npm link", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with the cli:link
command, but not having it added to pretest
. This means that any time someone runs tests, they're going to lose their existing global installation of the CLI and have it replaced with the locally-linked one. I expect this would cause havoc for contributors down the line.
I'm testing this right now to see if this fixes the issue with tests failing on Windows based on http://yeoman.io/authoring/ I'll ping the team if it works and is ready for review. |
package.json
Outdated
@@ -38,7 +38,7 @@ | |||
"build": "lerna run --loglevel=silent build", | |||
"build:current": "lerna run --loglevel=silent build:current", | |||
"pretest": "npm run build:current && npm run cli:link", | |||
"cli:link": "cd packages/cli/generators && npm link && cd ../../..", | |||
"cli:link": "cd packages/cli/generators/app && npm link && cd ../controller && npm link && ../extension && npm link && ../project && npm link && cd ../../..", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is completely wrong. Can you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note we don't depend on global installation of generators as @loopback/cli
does not use yo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll have to see if I can get my hands on a windows machine as I see a lot of tests failing on AppVeyor with the following message:
Error: You don't seem to have a generator with the name “loopback4:C:\projects\loopback-next\packages\cli\generators\app” installed.
But help is on the way:
You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/.
Install them with npm install generator-loopback4:C:\projects\loopback-next\packages\cli\generators\app.
To see all your installed generators run yo without any arguments. Adding the --help option will also show subgenerators.
If yo cannot find the generator, run yo doctor to troubleshoot your system.
at Environment.create (packages\cli\node_modules\yeoman-environment\lib\environment.js:368:9)
at Object.exports.testSetUpGen (packages\cli\test\test-utils.js:15:14)
at Context.it (packages\cli\test\base-generator.js:15:29)
I think I know what causes the Windows build issue now. There are a few places that we use
We need to use |
* test: run cli tests in top level npm test * fix(cli): use path.sep to be platform agnostic
Description
CLI Tests aren't run as part of top level
npm test
. Test count before change was 609. After this change it is 694.Related issues
Checklist