Skip to content

Commit bc1c5cc

Browse files
committed
chore: Karma 6 config updates
1 parent 3ab23dc commit bc1c5cc

File tree

2 files changed

+65
-37
lines changed

2 files changed

+65
-37
lines changed

karma.conf.js

+42-30
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
// Karma configuration
55

6-
const credentialsPromise = require('@aws-sdk/credential-provider-node').defaultProvider()()
6+
const credentialsPromise =
7+
require('@aws-sdk/credential-provider-node').defaultProvider()()
8+
const webpack = require('webpack')
79

810
module.exports = function (config) {
911
process.on('infrastructure_error', (error) => {
@@ -20,62 +22,72 @@ module.exports = function (config) {
2022

2123
config.set({
2224
basePath: '',
23-
frameworks: ['mocha', 'chai'],
25+
frameworks: [ 'mocha', 'chai', 'webpack'],
2426
files: [
25-
'modules/*-browser/test/**/*.ts',
26-
'modules/web-crypto-backend/test/**/*.ts',
27+
'modules/*-browser/build/module/test/*.js',
28+
'modules/material-management/build/module/test/*.js',
29+
'modules/raw-keyring/build/module/test/*.js',
30+
'modules/kms-keyring/build/module/test/*.js',
31+
// 'modules/cache-material/build/module/test/*.js',
32+
'modules/serialize/build/module/test/*.js',
33+
'modules/web-crypto-backend/build/module/test/*.js',
2734
],
2835
preprocessors: {
29-
'modules/*-browser/test/**/*.ts': ['webpack', 'credentials'],
30-
'modules/web-crypto-backend/test/**/*.ts': ['webpack', 'credentials'],
36+
'modules/**/build/module/test/*.js': ['webpack', 'credentials'],
3137
},
3238
webpack: {
3339
resolve: {
34-
extensions: ['.ts', '.js'],
40+
extensions: ['.js'],
3541
},
3642
mode: 'development',
3743
module: {
3844
rules: [
3945
{
40-
test: /\.tsx?$/,
41-
use: [
42-
{
43-
loader: 'ts-loader',
44-
options: {
45-
logInfoToStdOut: true,
46-
projectReferences: true,
47-
configFile: `${__dirname}/tsconfig.module.json`,
48-
},
49-
},
50-
],
51-
exclude: /node_modules/,
46+
// yauzl is only used in the node cli for browser integration
47+
test: /yauzl/,
48+
use: 'null-loader',
5249
},
5350
{
54-
test: /\.ts$/,
55-
exclude: [/\/test\//],
56-
enforce: 'post',
51+
test: /\.js/,
52+
// msrcrypto.js is are outside dependances
53+
// and should not be intremented or impact code coverage.
54+
// fixtures.js is a test file, not an entry point
55+
exclude: /(node_modules)|(msrcrypto.js)|(fixtures.js)/,
5756
use: {
58-
loader: 'istanbul-instrumenter-loader',
59-
options: { esModules: true },
60-
},
61-
},
57+
loader: "@jsdevtools/coverage-istanbul-loader",
58+
options: {
59+
// produceSourceMap: true
60+
}
61+
}
62+
}
6263
],
6364
},
65+
plugins: [
66+
new webpack.ProvidePlugin({
67+
Buffer: ['buffer', 'Buffer'],
68+
}),
69+
],
6470
stats: {
6571
colors: true,
6672
modules: true,
6773
reasons: true,
6874
errorDetails: true,
6975
},
70-
devtool: 'inline-source-map',
71-
node: {
72-
fs: 'empty',
76+
devtool: 'source-map',
77+
resolve: {
78+
fallback: {
79+
fs: false,
80+
crypto: false,
81+
},
7382
},
7483
},
7584
coverageIstanbulReporter: {
7685
reports: ['json'],
77-
dir: '.karma_output',
86+
combineBrowserReports: true,
7887
fixWebpackSourcePaths: true,
88+
dir: '.karma_output',
89+
skipFilesWithNoCoverage: true,
90+
// verbose: true,
7991
},
8092
plugins: [
8193
{

modules/integration-browser/karma.conf.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// Karma configuration
55
const { readFileSync } = require('fs')
6+
const webpack = require('webpack')
67

78
module.exports = function (config) {
89
// karma-parallel will use the number CPUs as the default number of browsers to spawn
@@ -17,36 +18,51 @@ module.exports = function (config) {
1718
'fixtures/decrypt_tests.json',
1819
'fixtures/encrypt_tests.json',
1920
'fixtures/decrypt_oracle.json',
20-
'/fixtures/concurrency.json',
21+
'fixtures/concurrency.json',
2122
{
2223
pattern: 'fixtures/*.json',
2324
included: false,
2425
served: true,
2526
watched: false,
2627
nocache: true,
2728
},
28-
'build/module/integration.decrypt.test.js',
29-
'build/module/integration.encrypt.test.js',
29+
'build/module/src/*test.js',
3030
],
3131
preprocessors: {
32-
'build/module/integration.decrypt.test.js': ['webpack', 'credentials'],
33-
'build/module/integration.encrypt.test.js': ['webpack', 'credentials'],
32+
'./build/module/src/*.js': ['webpack', 'credentials'],
3433
'./fixtures/decrypt_tests.json': ['json_fixtures'],
3534
'./fixtures/encrypt_tests.json': ['json_fixtures'],
3635
'./fixtures/decrypt_oracle.json': ['json_fixtures'],
3736
'./fixtures/concurrency.json': ['json_fixtures'],
3837
},
3938
webpack: {
39+
module: {
40+
rules: [
41+
{
42+
// yauzl is only used in the node cli for browser integration
43+
test: /yauzl/,
44+
use: 'null-loader',
45+
},
46+
]
47+
},
4048
mode: 'development',
4149
stats: {
4250
colors: true,
4351
modules: true,
4452
reasons: true,
4553
errorDetails: true,
4654
},
55+
plugins: [
56+
new webpack.ProvidePlugin({
57+
Buffer: ['buffer', 'Buffer'],
58+
}),
59+
],
4760
devtool: 'inline-source-map',
48-
node: {
49-
fs: 'empty',
61+
resolve: {
62+
fallback: {
63+
fs: false,
64+
crypto: false,
65+
},
5066
},
5167
},
5268
plugins: [

0 commit comments

Comments
 (0)