gpt4 book ai didi

javascript - Node JS Mocha 测试用例未运行

转载 作者:太空宇宙 更新时间:2023-11-04 01:57:07 24 4
gpt4 key购买 nike

我正在尝试建立一个带有测试用例的测试套件。由于某种原因,我们的射击没有任何钩子(Hook),所以我使测试用例尽可能简单。除了前面描述的那一条之外,仍然没有打印出任何 debug.log。这几乎就像代码没有看到我的任何 Mocha 测试。我在本地安装了 mocha 作为开发依赖项。它还返回许多通过的测试用例,即使我的代码中没有那么多的测试用例。我尝试卸载并重新安装 Mocha 。

终端返回**/测试/runner.js进入组织运行者配置设置数据库信息:mongodb://xxxxx:xxxxxxxx@localhost/icpDB

657 次测试。 0 次失败。 268 毫秒

进程已完成,退出代码为 0

    const mocha = require('mocha');
const chai = require('chai');
const debug = require('debug');

debug.log('Entered Org Runner');
describe('Org api test suite', function () {
before(function (done) {
debug.log('Entered Org Before');
done();
});
after(function (done) {
debug.log('Entered Org After');
done();
});

it('should create a new org', function (done) {
debug.log('Entered Create Org It');
done();
});

describe('GET Orgs', function () {
it('should respond with an array of orgs', function (done) {
debug.log('Entered Get Orgs It');
done();
});
});

describe('GET Org', function () {
it('should get a org by id', function (done) {
debug.log('It: should get a org by id');
done();
});

it('should throw an error for invalid id', function (done) {
debug.log('It: should throw an error for invalid id');
done();
});
});

describe('Update Org', function () {
it('should update an existing org', function (done) {
debug.log('should update an existing org');
done();
});
});

describe('Delete Org', function () {
it('should delete an existing org', function (done) {
debug.log('should delete an existing org');
done();
});
});
});

最佳答案

事实证明问题出在我的 package.json 中使用 --recursive 。其中一个测试用例导致 Mocha 退出。当我直接将其指向上面的特定文件时,它会按预期执行。

关于javascript - Node JS Mocha 测试用例未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47483159/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com