|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2017 Google Inc. All rights reserved. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +var webpack = require('webpack'); |
| 19 | +var path = require('path'); |
| 20 | +var LwcWebpackPlugin = require('lwc-webpack-plugin'); |
| 21 | + |
| 22 | +module.exports = function(config) { |
| 23 | + config.set({ |
| 24 | + plugins: [ |
| 25 | + 'karma-chrome-launcher', |
| 26 | + 'karma-firefox-launcher', |
| 27 | + require(path.resolve(__dirname, '../__shared__/karma-plugins/karma-mocha')), |
| 28 | + 'karma-sourcemap-loader', |
| 29 | + 'karma-webpack', |
| 30 | + require(path.resolve(__dirname, '../__shared__/karma-plugins/karma-custom-html-reporter')), |
| 31 | + require(path.resolve(__dirname, '../__shared__/karma-plugins/karma-custom-json-reporter')) |
| 32 | + ], |
| 33 | + browsers: ['ChromeHeadless', 'FirefoxHeadless'], // run in Chrome and Firefox |
| 34 | + customLaunchers: { |
| 35 | + FirefoxHeadless: { |
| 36 | + base: 'Firefox', |
| 37 | + flags: [ '-headless' ], |
| 38 | + displayName: 'FirefoxHeadless' |
| 39 | + }, |
| 40 | + }, |
| 41 | + singleRun: true, // set this to false to leave the browser open |
| 42 | + frameworks: ['mocha'], // use the mocha test framework |
| 43 | + files: [ |
| 44 | + 'tests.webpack.js' // just load this file |
| 45 | + ], |
| 46 | + preprocessors: { |
| 47 | + 'tests.webpack.js': ['webpack', 'sourcemap'] // preprocess with webpack and our sourcemap loader |
| 48 | + }, |
| 49 | + reporters: ['dots', 'custom-html', 'custom-json'], // report results in these formats |
| 50 | + htmlReporter: { |
| 51 | + outputFile: path.resolve(__dirname, './results/results.html'), |
| 52 | + pageTitle: 'LWC + Custom Elements', |
| 53 | + groupSuites: true, |
| 54 | + useCompactStyle: true |
| 55 | + }, |
| 56 | + jsonResultReporter: { |
| 57 | + outputFile: path.resolve(__dirname, './results/results.json') |
| 58 | + }, |
| 59 | + webpack: { // kind of a copy of your webpack config |
| 60 | + mode: 'development', |
| 61 | + // devtool: 'inline-source-map', // just do inline source maps instead of the default |
| 62 | + resolve: { |
| 63 | + modules: [ |
| 64 | + path.resolve(__dirname, '../__shared__/webcomponents/src'), |
| 65 | + path.resolve(__dirname, './node_modules') |
| 66 | + ] |
| 67 | + }, |
| 68 | + plugins: [ |
| 69 | + new LwcWebpackPlugin({ |
| 70 | + modules: [ |
| 71 | + { dir: "src/modules" } |
| 72 | + ] |
| 73 | + }) |
| 74 | + ], |
| 75 | + module: { |
| 76 | + rules: [ |
| 77 | + { |
| 78 | + test: /\.js$/, |
| 79 | + exclude: /node_modules/, |
| 80 | + use: { |
| 81 | + loader: 'babel-loader' |
| 82 | + } |
| 83 | + } |
| 84 | + ] |
| 85 | + } |
| 86 | + }, |
| 87 | + webpackServer: { |
| 88 | + // noInfo: true // please don't spam the console when running in karma! |
| 89 | + } |
| 90 | + }); |
| 91 | +}; |
0 commit comments