karma.base.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const alias = require('../../scripts/alias')
  2. const featureFlags = require('../../scripts/feature-flags')
  3. const webpack = require('webpack')
  4. const webpackConfig = {
  5. mode: 'development',
  6. module: {
  7. rules: [
  8. {
  9. test: /\.js$/,
  10. loader: 'babel-loader',
  11. exclude: /node_modules/
  12. },
  13. {
  14. test: /\.tsx?$/,
  15. exclude: /node_modules/,
  16. loader: 'ts-loader',
  17. },
  18. ]
  19. },
  20. resolve: {
  21. alias: alias,
  22. extensions: ['.tsx', '.ts', '.js'],
  23. fallback: {
  24. 'stream': require.resolve("stream-browserify")
  25. }
  26. },
  27. plugins: [
  28. new webpack.DefinePlugin({
  29. __WEEX__: false,
  30. 'process.env': {
  31. TRANSITION_DURATION: process.env.CI ? 100 : 50,
  32. TRANSITION_BUFFER: 10,
  33. ...featureFlags
  34. }
  35. })
  36. ],
  37. devtool: 'inline-source-map'
  38. }
  39. // shared config for all unit tests
  40. module.exports = {
  41. frameworks: ['jasmine', 'webpack', 'karma-typescript'],
  42. files: [
  43. './index.js',
  44. "src/**/*.ts" // *.tsx for React Jsx
  45. ],
  46. preprocessors: {
  47. './index.js': ['webpack', 'sourcemap'],
  48. "**/*.ts": ["karma-typescript", 'webpack', 'sourcemap'] // *.tsx for React Jsx
  49. },
  50. webpack: webpackConfig,
  51. webpackMiddleware: {
  52. noInfo: true
  53. },
  54. plugins: [
  55. 'karma-jasmine',
  56. 'karma-mocha-reporter',
  57. 'karma-sourcemap-loader',
  58. 'karma-webpack',
  59. 'karma-typescript'
  60. ]
  61. }