Leo*_*oso 5 typescript karma-jasmine karma-mocha webpack visual-studio-code
我想在 Visual Studio Code 上调试一些在以下堆栈上运行的测试:Typescript + Karma + Mocha + Chai + Webpack + Chrome Debugger Extension。
问题:它永远不会到达断点。如果我重新启动测试(从绿色箭头开始),它会到达断点,但我无法评估任何变量。它说 ReferenceError: myVariable is not defined。任何帮助表示赞赏...
var webpackConfig = require("./webpack.config");
module.exports = function (config) {
config.set({
basePath: "",
frameworks: ["mocha", "sinon", "chai", "karma-typescript"],
files: [
{ pattern: "src/**/*.ts" },
{ pattern: "src/**/*.js.map", included: false }
],
exclude: [
],
preprocessors: {
"src/**/*.ts": ["webpack", "sourcemap"],
"src/**/*.ts": [ "karma-typescript", "sourcemap"],
},
webpack: {
module: webpackConfig.module,
resolve: webpackConfig.resolve
},
karmaTypescriptConfig: {
karmaTypescriptConfig: true
},
browsers: ["ChromeDebugging", "PhantomDebugging"],
reporters: ["progress", "karma-typescript"],
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
singleRun: false,
concurrency: Infinity,
plugins: [
require("karma-sinon"),
require("karma-chai"),
require("karma-chrome-launcher"),
require("karma-phantomjs-launcher"),
require("karma-webpack"),
require("karma-mocha"),
require("karma-typescript"),
require("karma-sourcemap-loader")
],
customLaunchers: {
ChromeDebugging: {
base: "Chrome",
flags: ["--remote-debugging-port=9222"],
debug: true
},
PhantomDebugging: {
base: "PhantomJS",
options: {
windowName: "phantom-window",
settings: {
webSecurityEnabled: false
},
flags: ["--load-images=true"],
debug: true
}
}
},
})
}
Run Code Online (Sandbox Code Playgroud)
const path = require("path");
const WriteFilePlugin = require("write-file-webpack-plugin");
module.exports = {
entry: "./src/example/example.ts",
devtool: "source-map",
module: {
rules: [
{
test: /\.ts?$/,
use: "ts-loader",
exclude: /node_modules/
}
]
},
resolve: {
extensions: [".ts", ".js"]
},
plugins: [
new WriteFilePlugin()
],
output: {
filename: "example.js",
path: path.resolve(__dirname, "./dist")
}
Run Code Online (Sandbox Code Playgroud)
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug tests in Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"sourceMapPathOverrides": {
"webpack:///*": "${webRoot}/src/*"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1277 次 |
| 最近记录: |