karma-runner / karma-runner/karma

How to show full stack traces?

Open
#2,989 2 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Expected behaviour

I'd like to see full stack traces

### Actual behaviour

I've tried Mocha, Jasmine, Chrome headless, electron, and various preprocessors, but in every case I see errors of this format:

```
Electron 2.0.0 (Node 8.9.3) ERROR
{
"message": "Uncaught TypeError: Illegal constructor\nat /home/trusktr/Downloads/src/trusktr+lowclass/src/index.js:1:11\n\nundefined",
"str": "Uncaught TypeError: Illegal constructor\nat /home/trusktr/Downloads/src/trusktr+lowclass/src/index.js:1:11\n\nundefined"
}
```

How do I enable full stack traces?

### Environment Details

- Karma version (output of `karma --version`): 2.0.2
- Relevant part of your `karma.config.js` file: Doesn't matter, the error format seems to be the same after trying different preprocessors, launchers, browsers, and frameworks.

### Steps to reproduce the behaviour

1. Run any test

---

My config looks like this (at the moment):

```js
const CWD = process.cwd()
const glob = require('globby')
const fs = require('fs')
const mkdirp = require('mkdirp')

let testFiles = null

glob([
CWD+'/src/**/*.test.js',
CWD+'/tests/**/*.js',
]).then(paths => testFiles = paths)

// wait for glob call to finish
while (!testFiles) {
require('deasync').sleep(100)
}

testFiles.forEach(file => {
const relativeFile = file.replace(CWD, '')
const relativePath = dirname(relativeFile)

mkdirp( CWD + '/.test-build' + relativePath )

fs.writeFileSync( CWD + '/.test-build' + relativeFile, `
require('@babel/register')({
presets: [ ['@babel/preset-env', { targets: { node: 9 } }] ],
sourceMap: 'inline',
})

require( '${ file }' )
` )
})

function dirname(fullname) {
const parts = fullname.split('/')
parts.pop()
return parts.join('/')
}

module.exports = function(config) {

config.set({

frameworks: ['jasmine', 'stacktrace'],
reporters: ['spec'],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
concurrency: Infinity,
basePath: CWD,

browsers: ['Electron'],
files: [
'.test-build/**/*.js',
],
preprocessors: {
'.test-build/**/*.js': ['electron'],
},
client: {
// otherwise "require is not defined"
useIframe: false,
loadScriptsViaRequire: true,
},

})

}
```

Contributor guide

Open the contributing guide

Research direction

Start with the reported karma.config.js settings, especially the stacktrace framework, Electron browser, electron preprocessor, and source maps in the generated .test-build files. Reproduce the issue with the listed Karma 2.0.2 environment and compare the resulting error output with the expected full stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.