【问题标题】:Grunt not finding mocha browser testsGrunt 找不到 mocha 浏览器测试
【发布时间】:2019-11-14 18:50:10
【问题描述】:

我正在学习本教程: https://gist.github.com/maicki/7781943

这是我的 grunt 文件

// Gruntfile.js
module.exports = function(grunt){
    grunt.initConfig({
      pkg: grunt.file.readJSON('package.json'),

      //Mocha 
        mocha: {
            all: {
                src: ['tests/spec.html']
            },
            options: {
                run: true,
                reporter: 'Spec',
                growlOnSuccess: false
            }
        }

    });
    //Load grunt mocha task
    grunt.loadNpmTasks('grunt-mocha')

    grunt.registerTask('default', ['mocha']);
  };

除了本指南的建议之外,我还设置了以下内容:

ran bower init inside of the tests folder.
generating the following:
  "description": "",
  "main": "",
  "license": "MIT",
  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ]

我完成了这个,因为在运行该命令之前没有找到测试。

当我从命令行运行 grunt 时,我得到以下信息: 测试:tests/spec.html

0 传递(0ms)

0 次通过! (0.00s)

这里是 spec.html 页面和带有单元测试的 webspec.js 页面的要点: https://gist.github.com/dhuang612/83dcba46e0a70c107a3e081c5e5dca12

感谢您提供的任何帮助!

【问题讨论】:

    标签: javascript gruntjs mocha.js bower


    【解决方案1】:

    我做了一些研究发现

    https://github.com/shellscape/mocha-chrome
    

    我能够将其配置为在命令行中运行浏览器测试。 然后我使用另一个 npm 包同时调用来同时运行单元测试和浏览器测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多