Comments (15)
You can do npm run test:server:once -- --inspect
after putting debugger
in the test you want to break on, then open chrome://inspect.
You can also just commit or push with --no-verify
to skip running the tests.
from pantry-for-good.
There are some issues with the tests lately, I'm not sure what the problem is. You can run in watch mode with npm run test:server
or npm run test:client
from pantry-for-good.
OK, thanks
from pantry-for-good.
How can I debug into the tests? I really want to find out the source of the problem because I can't even commit with the failing tests and I don't want to change all the commit hook stuff
from pantry-for-good.
Thank you very much for all the help you provide. It's a pleasure to work like this.
from pantry-for-good.
I did not succeed doing it. By "putting the debugger in the test" do you mean setting the breakpoint? I don't know how chrome would be able to read the breakpoints I set in vs code.
from pantry-for-good.
Thanks! I mean the debugger statement (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger), sorry I thought it might not have been that clear too.
It's also not great because you have to refresh chrome i think every time you re-run the tests, but I'm not sure there's a better way.
from pantry-for-good.
But I think removing the :once
would be correct, right? Otherwise, I don't see anything appearing in chrome://inspect
But even with the test running continuously, it didn't work.
I inserted the debugger like that (in server/tests/user.spec.js):
it('admins can set other users as admins', async function(){
const user = await User.create({
firstName: 'first',
lastName: 'last',
email: '[email protected]',
roles: [],
provider: 'local',
password: '12345678'
})
const adminUser = createTestUser('admin', ADMIN_ROLE)
const adminSession = await createUserSession(adminUser)
const adminReq = supertest.agent(adminSession.app)
debugger;
await adminReq.put(`/api/admin/users/${user._id}`)
.send({ isAdmin: true })
.expect(200)
const updatedUser = await User.findById(user._id).lean()
expect(updatedUser).to.have.property('roles')
expect(updatedUser.roles).to.include(ADMIN_ROLE)
})
Then I ran npm run test:server -- --inspect
Then, in chrome://inspect, I clicked "inspect" in the red marked area:
This window opened:
Now im not sure how to continue
from pantry-for-good.
@jspaine: I don't wanna rush you but want to make sure you have seen I'm still having trouble ;) It's totally fine if you don't have time at the moment ... it's not super urgent but would be great to know.
from pantry-for-good.
I am able to debug the server tests directly in VScode with this configuration in my .vscode/launch.json file.
{
"name": "Debug Server Tests",
"type": "node",
"request": "launch",
"protocol": "inspector",
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--no-timeouts",
"--color",
"--require",
"babel-register",
"--require",
"server/entry.test.js",
"./server/tests/**/*.spec.js"
],
"smartStep": true,
"skipFiles": [
"node_modules/**/*.js",
"<node_internals>/**/*.js"
],
"env": {
"NODE_ENV": "test"
}
}
There is a problem where the breakpoints get moved to the last line of the file when I launch the tests. So I have to re-add the breakpoints while the test is running each time I debug the tests. There may be a setting with sourcemaps that could fix this.
from pantry-for-good.
Thanks! I'll try it
from pantry-for-good.
I got the breakpoints working by adding "sourceMaps": true
in the .vscode/launch.json configuration. Then I changed the .babelrc file to look like
"presets" : [
"flow"
],
"plugins": [
"transform-es2015-modules-commonjs",
"transform-async-to-generator",
"transform-object-rest-spread"
],
"env": {
"test": {
"plugins": ["istanbul", "babel-plugin-rewire"],
"sourceMaps": true,
"retainLines": true
}
}
}
from pantry-for-good.
Great, works for me, too!
from pantry-for-good.
Thanks!
from pantry-for-good.
@jspaine : I think the error is a mongodb related one. Maybe switching to the library referred here will help: https://github.com/chevex-archived/mongoose-auto-increment/issues/74
from pantry-for-good.
Related Issues (20)
- Not able to restart app HOT 4
- Add Customer Name to Packed Packages List HOT 3
- Packed package list create a 'contents' tool-tip HOT 2
- Question about debugging HOT 17
- Register as a customer shows not authorized from trying to get foods HOT 1
- "Password should be longer" should be displayed to the user, in case, while trying to register a new membership HOT 3
- how do I recreate the fb-dev database? HOT 4
- 'Unknown user or invalid password' should be displayed to the user, in case, while trying to Sign In HOT 9
- Sign up form not validating properly
- Notifications HOT 4
- Issues with running on Windows 10 HOT 2
- secrets.js api keys not being integrated HOT 4
- Proxy google maps api through the server
- Deployment - use data disk for mongodb data
- Deployment - allow passing secrets into the app
- Volunteer Scheduling
- Inventory - Scan and lookup product barcodes on openfoodfacts.org HOT 1
- Use of common constants HOT 1
- npm not working while deploying project locally HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pantry-for-good.