mocha.js

Node.js Mocha Testing Restful API Endpoints and Code Coverage

荒凉一梦 提交于 2021-01-21 09:20:51
问题 I've been really enjoying Istanbul and experimenting with other Node.js coverage libraries as well, but I have an issue. Nearly all of my unit tests are HTTP calls to my API like so: it('should update the customer', function (done) { superagent.put('http://myapp:3000/api/customer') .send(updatedData) .end(function (res) { var customer = res.body; expect(res.statusCode).to.equal(200); expect(customer.name).to.equal(updatedData.name); done(); }); }); As opposed to actually requiring the

How to use Mocha and Jest with TypeScript without conflicts?

时光总嘲笑我的痴心妄想 提交于 2021-01-21 07:04:50
问题 I'm trying to install Mocha and Jest with types on one project. We use strict typecheck, so I get errors related to conflicting globals type. I've tried to create ambiguous module declaration, defining only Mocha in types at tsconfig . I've been trying to remove Jest's declaration - but that would partially help. Disabling strict typecheck or lib check is not an option. I expected to work it properly, but instead got the next errors. node_modules/@types/jest/index.d.ts(29,13): error TS2403:

How to use Mocha and Jest with TypeScript without conflicts?

筅森魡賤 提交于 2021-01-21 07:03:11
问题 I'm trying to install Mocha and Jest with types on one project. We use strict typecheck, so I get errors related to conflicting globals type. I've tried to create ambiguous module declaration, defining only Mocha in types at tsconfig . I've been trying to remove Jest's declaration - but that would partially help. Disabling strict typecheck or lib check is not an option. I expected to work it properly, but instead got the next errors. node_modules/@types/jest/index.d.ts(29,13): error TS2403:

multiple mocha tests fail if run together in Visual Studio

三世轮回 提交于 2021-01-20 12:01:13
问题 I'm brand new to trying to create unit tests but this seems pretty basic and I can't figure out why it is giving me errors. I have a node.js project in Visual Studio. If add one mocha test file as shown below everything works fine: // file: UnitTest.js var assert = require('assert'); describe('Test Suite 1', function () { it('Test 1', function () { assert.ok(true, "This shouldn't fail"); }); }); describe('Test Suite 7', function () { it('Test 7', function () { assert.ok(true, "This shouldn't

multiple mocha tests fail if run together in Visual Studio

我的梦境 提交于 2021-01-20 12:00:38
问题 I'm brand new to trying to create unit tests but this seems pretty basic and I can't figure out why it is giving me errors. I have a node.js project in Visual Studio. If add one mocha test file as shown below everything works fine: // file: UnitTest.js var assert = require('assert'); describe('Test Suite 1', function () { it('Test 1', function () { assert.ok(true, "This shouldn't fail"); }); }); describe('Test Suite 7', function () { it('Test 7', function () { assert.ok(true, "This shouldn't