Issue running node.js unit tests in Visual Studio

非 Y 不嫁゛ 提交于 2021-02-11 13:37:37

问题


I tried asking a slightly more specific question here that has not received any answers so I'll try a little more generalized question.

I'm new to unit testing in node.js and just following some simple demo's. For some reason I encounter issues when trying to include more than one describe in test file or when nesting them. The other link I referenced above was for multiple describes in a file causing tests in other files to fail for some odd reason. I also have issues nesting. I created a simple unit test that looks has one describe() with several it() inside it. I then created so many it() that I decided to group them in their own nested describe() that I saw recommended in many threads. My file now looked something like this:

const chai = require('chai');
const should = chai.should();

describe('Root', function() {
  it('Test 1', function() { <test> } );
  it('Test 2', function() { <test> } );
  describe('Folder 1', function() {
    it('F1T1', function() { <test> });
  });
});

At this point all is well. However, when I decide to implement another nested descibe everyhting goes south. So I put "Test 2" inside a nested describe as well and now I have this:

const chai = require('chai');
const should = chai.should();

describe('Root', function() {
  it('Test 1', function() { <test> } );
  describe('Folder A', function() {
    it('Test 2', function() { <test> } );
  });
  describe('Folder 1', function() {
    it('F1T1', function() { <test> });
  });
});

As soon as I do this everything starts failing. It seems to com back to the other issue where I have two describes in a row at the same level but my understanding is that is supposed to be ok. Anyone have a clue why this doesn't work or what I need to do?

来源:https://stackoverflow.com/questions/60353885/issue-running-node-js-unit-tests-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!