When I run my test using command line all my tests pass
describe('my tests', function () {
context('test a specific thing', function () {
it('should store a data into the database', function() {
// store data here and test that it's successful
});
it('should fetch that data we stored earlier', function() {
// fetch that data and test that it's successful
});
});
});
But when I run (Run All Tests) with the Mocha Sidebar extension for Visual Studio Code, then it says that no data was stored
...
it('should fetch that data we stored earlier', function() {
// fails to fetch and it returns 0 row of data
});
...
This got me thinking about the way I structured my test. Seeing that the plugin displays Run Suite | Debug Suite and Debug Item | Run Item above each of describe(), context(), and it(), I think each of these should be distinctly debuggable and runnable.
Should I not persist data through series of it()?
describe('my tests', function () {
context('test a specific thing', function () {
it('should store a data into the database', function() {
// store data here and test that it's successful
});
context('since storing worked, only test fetching here', function() {
before('store data', function () {
// expect storing to work now
});
it('should fetch that data we just stored', function() {
// fetch that data and test that it's successful
});
})
});
});
Aucun commentaire:
Enregistrer un commentaire