1
1
// https://github.com/karma-runner/karma-chrome-launcher
2
2
process . env . CHROME_BIN = require ( "puppeteer" ) . executablePath ( ) ;
3
3
require ( "dotenv" ) . config ( ) ;
4
- const { relativeRecordingsPath } = require ( "@azure-tools/test-recorder" ) ;
5
-
6
- process . env . RECORDINGS_RELATIVE_PATH = relativeRecordingsPath ( ) ;
7
-
4
+ const {
5
+ jsonRecordingFilterFunction,
6
+ isPlaybackMode,
7
+ isSoftRecordMode,
8
+ isRecordMode,
9
+ } = require ( "@azure-tools/test-recorder" ) ;
8
10
module . exports = function ( config ) {
9
11
config . set ( {
10
12
// base path that will be used to resolve all patterns (eg. files, exclude)
@@ -25,13 +27,15 @@ module.exports = function (config) {
25
27
"karma-coverage" ,
26
28
"karma-sourcemap-loader" ,
27
29
"karma-junit-reporter" ,
30
+ "karma-json-to-file-reporter" ,
31
+ "karma-json-preprocessor" ,
28
32
] ,
29
33
30
34
// list of files / patterns to load in the browser
31
35
files : [
32
36
"dist-test/index.browser.js" ,
33
37
{ pattern : "dist-test/index.browser.js.map" , type : "html" , included : false , served : true } ,
34
- ] ,
38
+ ] . concat ( isPlaybackMode ( ) || isSoftRecordMode ( ) ? [ "recordings/browsers/**/*.json" ] : [ ] ) ,
35
39
36
40
// list of files / patterns to exclude
37
41
exclude : [ ] ,
@@ -40,6 +44,7 @@ module.exports = function (config) {
40
44
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
41
45
preprocessors : {
42
46
"**/*.js" : [ "sourcemap" , "env" ] ,
47
+ "recordings/browsers/**/*.json" : [ "json" ] ,
43
48
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
44
49
// Preprocess source file to calculate code coverage, however this will make source file unreadable
45
50
"dist-test/index.js" : [ "coverage" ] ,
@@ -48,18 +53,12 @@ module.exports = function (config) {
48
53
// inject following environment values into browser testing with window.__env__
49
54
// environment values MUST be exported or set with same console running "karma start"
50
55
// https://www.npmjs.com/package/karma-env-preprocessor
51
- envPreprocessor : [
52
- "TEST_MODE" ,
53
- "ENDPOINT" ,
54
- "SEARCH_API_ADMIN_KEY" ,
55
- "SEARCH_API_ADMIN_KEY_ALT" ,
56
- "RECORDINGS_RELATIVE_PATH" ,
57
- ] ,
56
+ envPreprocessor : [ "TEST_MODE" , "ENDPOINT" , "SEARCH_API_ADMIN_KEY" , "SEARCH_API_ADMIN_KEY_ALT" ] ,
58
57
59
58
// test results reporter to use
60
59
// possible values: 'dots', 'progress'
61
60
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
62
- reporters : [ "mocha" , "coverage" , "junit" ] ,
61
+ reporters : [ "mocha" , "coverage" , "junit" , "json-to-file" ] ,
63
62
64
63
coverageReporter : {
65
64
// specify a common output directory
@@ -82,6 +81,11 @@ module.exports = function (config) {
82
81
properties : { } , // key value pair of properties to add to the <properties> section of the report
83
82
} ,
84
83
84
+ jsonToFileReporter : {
85
+ filter : jsonRecordingFilterFunction ,
86
+ outputPath : "." ,
87
+ } ,
88
+
85
89
// web server port
86
90
port : 9876 ,
87
91
@@ -112,6 +116,10 @@ module.exports = function (config) {
112
116
browserDisconnectTimeout : 10000 ,
113
117
browserDisconnectTolerance : 3 ,
114
118
119
+ browserConsoleLogOptions : {
120
+ terminal : ! isRecordMode ( ) ,
121
+ } ,
122
+
115
123
client : {
116
124
mocha : {
117
125
// change Karma's debug.html to the mocha web reporter
0 commit comments