Include sourcemap file in karma files section (#8839)

* Include sourcemap file in karma files section

so we can debug TypeScript source code for browser tests. One still
needs to disable code coverage first though to have the source mapping
working.

We Have to set the .js.map files' type to be 'html' to prevent karma from
treating them as the default js files. See http://karma-runner.github.io/5.0/config/files.html for more details.
This commit is contained in:
Jeremy Meng 2020-05-12 10:46:24 -07:00 коммит произвёл GitHub
Родитель 69026b4507
Коммит 1e02861f3a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
25 изменённых файлов: 71 добавлений и 33 удалений

Просмотреть файл

@ -25,7 +25,10 @@ module.exports = function(config) {
],
// list of files / patterns to load in the browser
files: ["test-browser/index.js"],
files: [
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude
exclude: [],

Просмотреть файл

@ -16,7 +16,10 @@ module.exports = function(config) {
plugins: ["karma-mocha", require("karma-chrome-launcher")],
// list of files / patterns to load in the browser
files: ["test-browser/index.js"],
files: [
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude
exclude: [],

Просмотреть файл

@ -28,7 +28,8 @@ module.exports = function(config) {
// Uncomment the cdn link below for the polyfill service to support IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
// "https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude
@ -40,7 +41,7 @@ module.exports = function(config) {
"**/*.js": ["env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
"test-browser/index.js": ["coverage"]
"dist-test/index.js": ["coverage"]
},
// inject following environment values into browser testing with window.__env__

Просмотреть файл

@ -24,7 +24,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
],
exclude: [],

Просмотреть файл

@ -28,7 +28,10 @@ module.exports = function(config) {
],
// list of files / patterns to load in the browser
files: ["test-browser/index.js"],
files: [
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude
exclude: [],

Просмотреть файл

@ -29,7 +29,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"test-browser/index.js"
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude

Просмотреть файл

@ -28,7 +28,8 @@ module.exports = function(config) {
// Uncomment the cdn link below for the polyfill service to support IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
// "https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude
@ -40,7 +41,7 @@ module.exports = function(config) {
"**/*.js": ["env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
"test-browser/index.js": ["coverage"]
"dist-test/index.browser.js": ["coverage"]
},
// inject following environment values into browser testing with window.__env__

Просмотреть файл

@ -30,14 +30,16 @@ module.exports = function(config) {
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor"
],
// list of files / patterns to load in the browser
files: ["test-browser/index.browser.js"].concat(
files: [
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
].concat(
isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []
),
@ -47,11 +49,11 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env", "sourcemap"],
"**/*.js": ["env"],
"recordings/browsers/**/*.json": ["json"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
"dist-test/index.browser.js": ["coverage"]
"test-browser/index.js": ["coverage"]
},
envPreprocessor: [

Просмотреть файл

@ -124,7 +124,6 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.7",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",

Просмотреть файл

@ -112,7 +112,7 @@ export function browserConfig(test = false) {
// Entry points - test files under the `test` folder(common for both browser and node), browser specific test files
baseConfig.input = ["dist-esm/test/*.spec.js", "dist-esm/test/browser/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "test-browser/index.browser.js";
baseConfig.output.file = "test-browser/index.js";
baseConfig.onwarn = (warning) => {
if (

Просмотреть файл

@ -1,6 +1,10 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config({ path: "../.env" });
const {
isPlaybackMode,
isSoftRecordMode
} = require("@azure/test-utils-recorder");
module.exports = function(config) {
config.set({
@ -31,8 +35,10 @@ module.exports = function(config) {
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"test-browser/index.js",
"recordings/browsers/**/*.json"
],
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
].concat(
isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []
),
// list of files / patterns to exclude
exclude: [],

Просмотреть файл

@ -90,6 +90,7 @@
},
"devDependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/test-utils-recorder": "^1.0.0",
"@microsoft/api-extractor": "7.7.11",
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-json": "^4.0.0",

Просмотреть файл

@ -32,7 +32,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
exclude: [],

Просмотреть файл

@ -32,7 +32,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
exclude: [],

Просмотреть файл

@ -32,7 +32,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
exclude: [],

Просмотреть файл

@ -32,7 +32,10 @@ module.exports = function(config) {
],
// list of files / patterns to load in the browser
files: ["dist-test/index.browser.js"].concat(
files: [
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(
isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []
),
@ -46,7 +49,7 @@ module.exports = function(config) {
"recordings/browsers/**/*.json": ["json"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
"test-browser/index.js": ["coverage"]
"dist-test/index.js": ["coverage"]
},
// inject following environment values into browser testing with window.__env__

Просмотреть файл

@ -29,7 +29,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"test-browser/index.js"
"test-browser/index.js",
{ pattern: "test-browser/index.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude

Просмотреть файл

@ -37,7 +37,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys,Symbol.iterator
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys|always,Symbol.iterator",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false },
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
// list of files / patterns to exclude

Просмотреть файл

@ -37,7 +37,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys,Symbol.iterator
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys|always,Symbol.iterator",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
// list of files / patterns to exclude

Просмотреть файл

@ -37,7 +37,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys,Symbol.iterator
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys|always,Symbol.iterator",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
// list of files / patterns to exclude

Просмотреть файл

@ -37,7 +37,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys,Symbol.iterator
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys|always,Symbol.iterator",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []),
// list of files / patterns to exclude

Просмотреть файл

@ -28,7 +28,8 @@ module.exports = function(config) {
// Uncomment the cdn link below for the polyfill service to support IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys
// "https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude
@ -40,7 +41,7 @@ module.exports = function(config) {
"**/*.js": ["env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
"test-browser/index.js": ["coverage"]
"dist-test/index.js": ["coverage"]
},
// inject following environment values into browser testing with window.__env__

Просмотреть файл

@ -18,7 +18,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude

Просмотреть файл

@ -30,7 +30,8 @@ module.exports = function(config) {
// polyfill service supporting IE11 missing features
// Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys
"https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.assign,Object.keys|always",
"dist-test/index.browser.js"
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
],
// list of files / patterns to exclude

Просмотреть файл

@ -36,7 +36,10 @@ module.exports = function(config) {
],
// list of files / patterns to load in the browser
files: ["dist-test/index.browser.js"].concat(
files: [
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: false }
].concat(
isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []
),
@ -50,7 +53,7 @@ module.exports = function(config) {
"recordings/browsers/**/*.json": ["json"]
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
// "test-browser/index.js": ["coverage"]
// "dist-test/index.js": ["coverage"]
},
envPreprocessor: [