Giter Site home page Giter Site logo

Comments (5)

4kochi avatar 4kochi commented on June 6, 2024

Can you please try another browser. The error message depends on the browser. I just want to make sure if it is a browser issue or an issue of the reporter.

Thanks

from karma-mocha-reporter.

lvthanh101 avatar lvthanh101 commented on June 6, 2024

hi @4kochi
mocha-failed

I saw log in chrome developer console, it still has no file path.
Note: my webpack is already configured to generate sourcemap for all code.

Thanks

from karma-mocha-reporter.

lvthanh101 avatar lvthanh101 commented on June 6, 2024

hi @4kochi
Do you know how to work around for this issue?

Thanks

from karma-mocha-reporter.

esayler avatar esayler commented on June 6, 2024

@lvthanh101

I had this same problem but I'm using webpack as a preprocessor. I'm not sure about a non-webpack focused solution, but I found a solution that'll work if you are using a build tool like webpack.

You'll need the karma-sourcemap-loader plugin/preprocessor.

Then, you include 'sourcemap' preprocessor after 'webpack' in the preprocessors object and then do devtool: 'inline-source-map' in your weback config of your karma.conf.js you can get what you're looking for.

here's my example karma.conf.js:

var webpackConfig = require('./webpack.config.js')

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['mocha', 'chai', 'sinon'],
    files: [
      { pattern: 'test/**/*.spec.jsx', watched: false, serverd: true, included: true },
      { pattern: 'test/**/*.spec.js', watched: false, serverd: true, included: true },
    ],
    exclude: [],
    preprocessors: {
      'test/**/*.spec.jsx': ['webpack', 'sourcemap'],
      'test/**/*.spec.js': ['webpack', 'sourcemap'],
    },
    webpack: {
      devtool: 'inline-source-map',
      module: webpackConfig.module,
      plugins: webpackConfig.plugins,
      externals: webpackConfig.externals,
      resolve: webpackConfig.resolve,
      performance: false,
    },
    webpackServer: {
      stats: 'errors-only',
    },
    reporters: ['progress', 'mocha'],
    mochaReporter: {
      colors: {
        warning: 'black',
        error: 'red',
      },
      showDiff: true,
    },
    client: {
      captureConsole: false,
    },
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    autoWatchBatchDelay: 1000,
    browsers: ['Chrome'],
    singleRun: false,
    concurrency: Infinity,
  })
}

Here's my example test file:

import chai from 'chai'
var expect = chai.expect
chai.should()

describe('Example Class', () => {
  describe('some stuff', () => {
    it('should do something', () => {
      true.should.not.be.ok
    })
  })
})

Example test output:
screenshot 2017-04-07 19 57 13

As you can see above there's now a sourcemap indicating the file of containing the failing test and the line of the failing assertion at the end of the failing test:

    at Context.<anonymous> (webpack:///test/ExampleTests.spec.js:12:25 <- test/ExampleTests.spec.js:13229:25)

from karma-mocha-reporter.

lvthanh101 avatar lvthanh101 commented on June 6, 2024

Hi @esayler

Thanks for your response. However, my karma config already has 'sourcemap' in preprocessor and devtool is 'inline-source-map'. So I cannot still solve this problem.

from karma-mocha-reporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.