1

我正在使用 Karma-Webpack。Karma Webpack 源地图不起作用

当我在 Chrome 中使用 karma 执行测试时,我的规范的源文件在调试器中显示为不可读。但是,被测系统文件(我的应用程序源)不可读

java脚本加载到浏览器,非常难以调试。任何人都可以帮助我将类型脚本加载到

调试器中的规范文件

在此处输入图像描述

webpack.test.config.js

var path = require('path'),
    webpack = require('webpack');

module.exports = {
    context: __dirname,
    output: {},
    cache: {},
    resolve: {
        extensions: ['.ts', '.js'],
        alias: {
            "cldr": path.resolve(__dirname, "node_modules/cldrjs/dist/cldr")
        }
    },
    plugins: [
        new webpack.SourceMapDevToolPlugin({
            filename: null,
            test: /\.(ts|js)($|\?)/i
        })
    ],
    module: {
        rules: [
            {
                test: /\.ts$/,
                loader: 'ts-loader'
            },
            { test: /\.html$/i, use: 'html-loader' },
            {
                test: /\.(js|ts)$/,
                enforce: 'post',
                loader: 'istanbul-instrumenter-loader',
                query: {
                    esModules: true
                },
                exclude: [
                    /index\.ts/,
                    /\.spec\.js$/,
                    /\.t\.ts$/,
                    /node_modules/,
                    /.bin/,
                    /decompressionworker\.ts/,
                    /\.(glsl|vs|fs)$/
                ]
            }]
    },
    watch: false
};

业力配置

// Karma configuration
// Generated on Wed Oct 18 2017 11:50:04 GMT+0530 (Sri Lanka Standard Time)
var webpackConfig = require('../webpack.test.config');

module.exports = function(config) {
  config.set({
    basePath: '',

    frameworks: ['jasmine'],

    files: [
       { pattern: "../node_modules/reflect-metadata/Reflect.js", include: true },
      './karma-bundle.js'
    ],

    webpack: webpackConfig,

    preprocessors: {
      './karma-bundle.js': ['webpack']
    },

    webpackMiddleware: {
      stats: 'normal'
    },

    plugins: [
      require('karma-coverage'),
      require('karma-coverage-istanbul-reporter'),
      require('karma-jasmine'),
      require('karma-mocha-reporter'),
      require('karma-webpack'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter')
    ],

    client: {
      clearContext: false,
    },

    reporters: ['progress', 'kjhtml', 'coverage-istanbul'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_INFO,

    autoWatch: true,

    browsers: ['Chrome'],

    singleRun: false,

    concurrency: Infinity,

    coverageIstanbulReporter: {
           reports: ['html', 'lcovonly', 'text-summary'],
           dir: 'coverage',
           fixWebpackSourcePaths: true,
           skipFilesWithNoCoverage: true,
           'report-config': {
             html: {
               subdir: 'html'
             }
           },

           thresholds: {
             emitWarning: true, // set to `true` to not fail the test command when thresholds are not met
             global: { // thresholds for all files
               statements: 100,
               lines: 100,
               branches: 100,
               functions: 100
             }
           }

         }
  })
}

业力捆绑.js

const tests = require.context('./ClientApp/views', true, /\.spec.ts$/);
tests.keys().forEach(tests);

4

0 回答 0