SourceMap position not found for trace: TypeError: ...
svi3c opened this issue ยท 19 comments
Hello,
I've got the following karma configuration:
module.exports = (config) ->
config.set
frameworks: ["browserify", "jasmine"]
files: [
"node_modules/angular/angular.js"
"node_modules/angular-mocks/angular-mocks.js"
"app/**/*.spec.js"
]
preprocessors:
"app/**/*.js": ["browserify"]
browserify:
debug: true
configure: (bundle) ->
bundle.once "prebundle", ->
bundle.transform "babelify"
reporters: ["dots"]
port: 8877
colors: true
logLevel: config.LOG_INFO
autoWatch: false
browsers: ["PhantomJS"]
singleRun: true
When I get an error, the stack trace cannot be linked with the source maps:
SourceMap position not found for trace: TypeError: undefined is not an object (evaluating '[...]') in http://localhost:8877/absolute/tmp/c6ec59ad61f294fd51d07305eeaf5c17.browserify?ed7e1e8ce42e802c4d614ba337bf1dc8ac6e27b9 (line 182)
Any Idea what's going wrong here?
Can we get some code please?
Sure!
The problem is that the issue occurs in a closed source project.
I'll boil it down to the essentials when I've got time.
I believe I have the same error testing React. my karma.conf.js looks like this:
module.exports = function(config) {
config.set({
basePath: ".",
frameworks: ['jasmine', 'browserify'],
preprocessors: {
'tests/**/*.js': ['babel', 'browserify']
},
babelPreprocessor:{
options: {
presets: ['es2015'],
sourceMap: 'inline'
}
},
browserify: {
debug: true,
transform: [ 'babelify'],
configure: function(bundle){
bundle.on("prebundle", function(){
bundle.external("react/addons");
bundle.external("react/lib/ReactContext");
bundle.external("react/lib/ExecutionEnvironment");
});
}
},
reporters: ['spec'],
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
files: [
'tests/**/*.js'
]
});
};
My one and only test file has:
'use strict';
import React from 'react';
import {mount} from 'enzyme';
import sinon from 'sinon';
import Footer from '../src/js/components/Footer';
describe('<Footer/>', () => {
it('renders footer <Footer/> component', () => {
const wrapper = mount(<Footer/>);
console.log(wrapper);
expect(wrapper.find('.app_footer')).to.have.length(1);
});
});
Footer component has only one div with class name '.app_footer'. The error I get is this:
SourceMap position not found for trace: TypeError: undefined is not an object (evaluating 'expect(wrapper.find('.app_wrapper')).to.have') in http://localhost:9876/absolute/var/folders/wr/hkjbf_wd3tnf5j9t2p8ndnt40000gn/T/40f5d6b577f0f7e57a2eb4aabc9edf46.browserify?d01138ff9d27c662c126752a88873bdf74683625 (line 61603)
http://localhost:9876/absolute/var/folders/wr/hkjbf_wd3tnf5j9t2p8ndnt40000gn/T/40f5d6b577f0f7e57a2eb4aabc9edf46.browserify?d01138ff9d27c662c126752a88873bdf74683625:61603:42
Sample.zip
This is my sample project. Btw, I only get that error when the test fails.
I got the same error.
Please use reactions to say "me too" instead of notifying everyone on a thread
This may not be specific to karma-browserify - I am using karma-webpack and am experiencing the same behavior.
That is what I thought, too. Did you find an upstream bug in TypeScript or a sourcemap library?
I have not tracked down the root cause in an upstream yet, but I am not using typescript, so that eliminates that possibility =-D
I have Typescript too and same error.
Any update on this?
I just had the same issue with Typescript 2.2.x
. I reverted to version 2.0.8
and the issue was fixed.
This is a bit random. But I had this issue. When I deleted a line that just has a ; on it the error disappeared.
I'm using typescript.
As indicated in the comments, this seems to be a TypeScript source map generation.
Can also happen if one of your typescript files has a compile error - in my case it was one of my test files as referenced by the error:
02 06 2017 15:16:54.630:WARN [reporter]: SourceMap position not found for trace:
undefined
PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR
{
"line": 104034,
"sourceURL": "src/test.ts",
....
I'm not using typescript and get this error. just regular source-map
.
I encountered this issue, and it turned out it is because I didn't use correct mode for webpack config in karma.conf.js
Solution
karma.conf.js
webpack: {
mode: 'development',
version
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
If you are using karma-sourcemap-loader
, try switching to karma-source-map-support
.
My case: Babel, no TypeScript, Webpack and not Browserify, I was using karma-sourcemap-loader
.
- When throwing errors or failing assertions in test, there would be anywhere from 2 to 12 "SourceMap position not found for trace" warnings for each thrown error, badly polluting the output. The errors themselves though were displayed correctly, source maps working.
- When using
console.error()
to print stack traces without halting execution, there would be the same "SourceMap position not found for trace" noise, but console output for errors would not be mapped, line numbers referencing compiled bundles, not original sources.
After switching, both use cases work perfectly fine, outputting mapped stack traces, no extra warnings.
This is likely not to be relevant to the OP's problem, but this issue comes up as the Google's top hit for "SourceMap position not found for trace", so I hope that'll help someone.