-
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
feat(cli): add vscode config files #1336
Conversation
"dist*/test/**/*.js", | ||
"-t", | ||
"0" | ||
] |
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 don't think we have tests for hello-world
.
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.
IMO, this should be there in case users want to build on top of hello-world
"cwd": "${workspaceRoot}", | ||
"args": [ | ||
"--opts", | ||
"${workspaceRoot}/test/mocha.opts", |
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 don't think we have test/mocha.opts
for this module.
"args": [ | ||
"--opts", | ||
"${workspaceRoot}/test/mocha.opts", | ||
"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.
This will not work. npm run build
produces both dist8
and dist10
directories. Your wildcard will match both Node.js 8.x and 10.x dist files, therefore each test will be run twice, and if you run on Node.js 8.x, the 10.x tests will fail on unsupported syntax/APIs.
"args": [ | ||
"--opts", | ||
"${workspaceRoot}/test/mocha.opts", | ||
"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.
Ditto, dist*
will not work well.
examples/hello-world/package.json
Outdated
"pretest": "npm run clean && npm run build:current", | ||
"test": "lb-mocha --allow-console-logs \"DIST/test\"", | ||
"posttest": "npm run lint", | ||
"test:dev": "lb-dist mocha DIST/test/**/*.js && npm run lint", |
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 think we should be using lb-mocha
instead of lb-dist mocha
in all test:dev
scripts, thoughts?
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.
agreed
0b1f63c
to
ce132b6
Compare
"name": "Run Mocha tests", | ||
<% if (project.loopbackBuild) { -%> | ||
"autoAttachChildProcesses": true, | ||
"program": "${workspaceRoot}/node_modules/.bin/lb-mocha", |
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.
There's a problem here where if we were using this config to debug and we end up hitting the restart button, we get timed out with an ECONNREFUSED error. The problem seems to be that the processes and its child processes don't exit out properly. I'd like to get some help with this if possible.
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.
IIRC, you need to invoke _mocha
directly if you want to debug the tests.
lb-mocha
creates a child process that creates another node process mocha
which creates the third child process `_mocha.
Maybe we should add a new option to lb-mocha
to tell our wrapper to start mocha in a debug mode? I am not sure if that would work with VS Code inspector though.
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 it's easier, then I am ok with leaving out launch.json
configuration from this initial pull request.
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.
We can already start mocha in debug mode by passing in --inspect
as an argument, but that doesn't seem to fix the problem of the timeout issue when restarting. This might be fixable if lb-mocha calls _mocha
instead of mocha
, but I think I'd rather address this in a separate issue.
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.
Fair enough 👍 Looks like you already understand this matter better than I do 😄
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.
Great start. For the examples/*
projects there is a lot of repetition on prettierrc
and prettierignore
files. Can we include these in @loopback/build
and then pass in the path to prettier
via flags:
--config ./node_modules/@loopback/build/config/prettier/.prettierrc
and
--ignore-path ./node_modules/@loopback/build/config/prettier/.prettierignore
in package.json
this way if we change config it only needs to happen in one place.
"label": "Build, Test and Lint", | ||
"type": "shell", | ||
"command": "npm", | ||
"args": ["--silent", "run", "test:dev"], |
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.
Shouldn't this be 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.
The 'advocated' development pattern according to DEVELOPING.md
was to have build:watch
running and then running the tests without building (since build:watch
takes care of that). test:dev
is just npm t
without the build step
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.
Ah ok. Makes sense. 👍
"label": "Watch and Compile Project", | ||
"type": "shell", | ||
"command": "npm", | ||
"args": ["--silent", "run", "build:watch"], |
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.
There is no matching build:watch
in package.json
.
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.
good catch!
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.
LGTM as far as I am concerned, please work with @virkt25 to iron out the details he pointed out.
examples/hello-world/package.json
Outdated
"pretest": "npm run clean && npm run build:current", | ||
"test": "lb-mocha --allow-console-logs \"DIST/test\"", | ||
"posttest": "npm run lint", | ||
"test:dev": "lb-mocha DIST/test/**/*.js && npm run lint", |
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.
Change npm run lint
to npm run posttest
-- this will help ensure consistency with the test
command.
I think doing npm run test -- --skip-scripts && npm run posttest
might be an overkill possible but will ensure the greatest consistency between the scripts.
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 like the npm run posttest
idea, but I'm a bit tripped up on the npm run test -- --skip-scripts
. Is the intention of that to skip the build process?
Nvm, figured out what you meant. Unfortunately, --skip-scripts
also disables npm test
because it's also considered a script. I know what consistency you want though, so I'm going to find out if there's a way to disable hooks from tests any other way. If there isn't, 🤷♂️
@virkt25 The use case for prettier config files IMO is for the users when they |
Checklist
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated