@Mariik

Почему Карма не запускает тест?

Привет.

В общем сделал я своми кривіми руками такой вот angular starter
// package.json
{
  "name": "SA-19KV",
  "version": "1.0.0",
  "description": "Project Boilerplate",
  "scripts": {
    "dev": "webpack-dev-server --content-base app/ --progress --colors ",
    "hot": "webpack-dev-server --content-base app/ --progress --colors --inline --hot",
    "test": "set NODE_ENV=test && karma start",
    "prod":"webpack -p"
  },
  "dependencies": {
    "angular": "1.5.0"
  },
  "devDependencies": {
    "angular-mocks": "^1.6.1",
    "babel-core": "^6.22.1",
    "babel-loader": "^6.2.10",
    "babel-preset-es2015": "6.6.0",
    "babel-preset-stage-0": "6.5.0",
    "chai": "^3.5.0",
    "css-loader": "^0.26.1",
    "html-webpack-plugin": "1.6.1",
    "karma": "^1.4.1",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-mocha": "^1.3.0",
    "karma-webpack": "^2.0.2",
    "mocha": "^3.2.0",
    "node-sass": "^4.4.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^4.1.1",
    "style-loader": "^0.13.1",
    "webpack": "1.12.13",
    "webpack-dev-server": "1.14.1"
  },
  "author": "Me :-)",
  "license": "ISC"
}


с вот такой конфой самого вебпака:

const path = require('path');
const appPath =path.join(__dirname , '/app/');
const rootEntryFile = appPath + 'index.js';
const loadersPath = path.join(__dirname, 'node_modules');

var webpack = require("webpack");

module.exports = {
    context: appPath,
    entry: rootEntryFile,
    output:{
        path:appPath,
        filename:'bundle.js'
    },
    resolveLoader: {
        root: loadersPath
    },
    plugins:[
        new webpack.DefinePlugin({
            TEST_ENV:process.env.NODE_ENV === "test"
        })
    ],
    module: {
        loaders: [
            { test: /\.js/, loader: "babel-loader"},
            { test: /\.html/, loader: "raw-loader"},
            { test: /\.css/, loader: "style!css"},
            {  test: /\.scss$/, loader: "style!css!sass-loader"}
        ]
    },
    devServer: {
        port: 7000,
    },
    devtool: 'source-map',
}


и с таким конфигом самой карм:

const path = require("path");
const webPackConfig = require("./webpack.config");
const entry = path.resolve(webPackConfig.context,webPackConfig.entry);

var processors = {};

processors[entry]=["webpack"];

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha','chai'],

    // list of files / patterns to load in the browser
    files: [entry],
    webpack:webPackConfig,
    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: processors,

    // list of files to exclude
    exclude: [
    ],

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    plugins:[
        require("karma-webpack"),
        "karma-chai",
        "karma-mocha",
        "karma-chrome-launcher"
    ],

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}

но вот беда с тестами... Карма вроде как и запускается, запускает хром, но тестов не видит. Есть какие то идеи как исправить?
  • Вопрос задан
  • 225 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы