简体   繁体   English

运行摩卡测试?

[英]Run a mocha test?

Good evening, i am learning about testing and have installed mocha.晚上好,我正在学习测试并安装了 mocha。 I have a basic test that just compares 2 numbers and i cant get it to run.我有一个基本测试,只比较 2 个数字,但我无法运行它。 could anyone explain to me why and how to fix this?谁能向我解释为什么以及如何解决这个问题?

Json Json

{  "scripts": {
  "test": "mocha test/**/*.js"
},
  "name": "image-gallery",
  "version": "1.0.0",
  "description": "",
  "main": "script-test.js",
  "directories": {
    "test": "script-test.js"
  },
 
  "author": "",
  "license": "ISC"
}

Test.js测试.js

const assert = require('assert');

describe('number test', function() {
    it('matching numbers', function() {
      assert.ok(2 === 2);
    });
  });

Did you install mocha by running this in your project directory?您是否通过在项目目录中运行它来安装 mocha?

npm install --save-dev mocha

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM