-
Notifications
You must be signed in to change notification settings - Fork 183
Add test:fast for faster unit test runs
#3179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
120d80f
refactor: optimize karma configuration for improved performance
BryanValverdeU 625e0ac
feat: add fast karma configuration and update package.json for debugging
BryanValverdeU 69757d1
refactor: streamline karma plugin declaration and update test scripts…
BryanValverdeU 4e60d1a
Merge branch 'master' into u/bvalverde/ttttttttttttest
BryanValverdeU 18f3c07
Merge branch 'master' of https://github.com/microsoft/roosterjs into …
BryanValverdeU c1074a7
refactor: update test commands to use fast karma configuration
BryanValverdeU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| const argv = require('minimist')(process.argv.slice(2)); | ||
| const components = argv.components !== true && argv.components; | ||
| const runCoverage = typeof argv.coverage !== 'undefined'; | ||
| const runFirefox = typeof argv.firefox !== 'undefined'; | ||
| const runChrome = typeof argv.chrome !== 'undefined'; | ||
|
|
||
| const rootPath = __dirname; | ||
|
|
||
| module.exports = function (config) { | ||
| const plugins = ['karma-webpack', 'karma-jasmine', 'karma-sourcemap-loader']; | ||
| const launcher = []; | ||
|
|
||
| if (runCoverage) { | ||
| plugins.push('karma-coverage-istanbul-reporter'); | ||
| } | ||
|
|
||
| if (runChrome) { | ||
| plugins.push('karma-chrome-launcher'); | ||
| launcher.push('Chrome'); | ||
| } | ||
|
|
||
| if (runFirefox) { | ||
| plugins.push('karma-firefox-launcher'); | ||
| launcher.push('Firefox'); | ||
| } | ||
|
|
||
| const tsConfig = { | ||
| compilerOptions: { | ||
| rootDir: rootPath, | ||
| declaration: false, | ||
| strict: false, | ||
| downlevelIteration: true, | ||
| transpileOnly: true, // Faster compilation - skip type checking | ||
| paths: { | ||
| '*': ['*', rootPath + '/packages/*'], | ||
| }, | ||
| }, | ||
| transpileOnly: true, // Enable faster transpilation | ||
| }; | ||
|
|
||
| const rules = runCoverage | ||
| ? [ | ||
| { | ||
| test: /lib(\\|\/).*\.ts$/, | ||
| use: [ | ||
| { loader: '@jsdevtools/coverage-istanbul-loader' }, | ||
| { | ||
| loader: 'ts-loader', | ||
| options: tsConfig, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| test: /test(\\|\/).*\.ts$/, | ||
| loader: 'ts-loader', | ||
| options: tsConfig, | ||
| }, | ||
| ] | ||
| : [ | ||
| { | ||
| test: /\.ts$/, | ||
| loader: 'ts-loader', | ||
| options: tsConfig, | ||
| }, | ||
| ]; | ||
|
|
||
| const settings = { | ||
| basePath: '.', | ||
| plugins, | ||
| client: { | ||
| components: components, | ||
| clearContext: false, | ||
| captureConsole: true, | ||
| }, | ||
| browsers: launcher, | ||
| files: ['tools/karma.test.all.js'], | ||
| frameworks: ['jasmine'], | ||
| preprocessors: { | ||
| 'tools/karma.test.all.js': ['webpack', 'sourcemap'], | ||
| }, | ||
| port: 9876, | ||
| colors: true, | ||
| logLevel: config.LOG_INFO, | ||
| autoWatch: true, | ||
| autoWatchBatchDelay: 300, // Batch file changes for better performance | ||
|
|
||
| // to avoid DISCONNECTED messages | ||
| browserDisconnectTimeout: 10000, // default 2000 | ||
| browserDisconnectTolerance: 1, // default 0 | ||
| browserNoActivityTimeout: 60000, //default 10000 | ||
| browserConsoleLogOptions: { | ||
| level: 'log', | ||
| format: '%b %T: %m', | ||
| terminal: true, | ||
| }, | ||
|
|
||
| singleRun: true, | ||
| captureTimeout: 60000, | ||
|
|
||
| webpack: { | ||
| mode: 'development', | ||
| devtool: 'eval-source-map', // Faster than inline-source-map | ||
| module: { | ||
| rules, | ||
| }, | ||
| resolve: { | ||
| extensions: ['.ts', '.tsx', '.js'], | ||
| modules: ['./packages', './node_modules'], | ||
| }, | ||
| // Workaround karma-webpack issue https://github.com/ryanclark/karma-webpack/issues/493 | ||
| // Got this solution from https://github.com/ryanclark/karma-webpack/issues/493#issuecomment-780411348 | ||
| optimization: { | ||
| splitChunks: false, | ||
| removeAvailableModules: false, // Performance optimization | ||
| removeEmptyChunks: false, // Performance optimization | ||
| }, | ||
| // Add filesystem caching for better performance | ||
| cache: { | ||
| type: 'filesystem', | ||
| cacheDirectory: require('path').join(rootPath, 'node_modules/.cache/webpack'), | ||
| }, | ||
| stats: 'errors-warnings', // Reduce console output | ||
| }, | ||
|
|
||
| // Concurrency level | ||
| // how many browser should be started simultaneous | ||
| concurrency: Infinity, | ||
| }; | ||
|
|
||
| if (runCoverage) { | ||
| settings.reporters = ['coverage-istanbul']; | ||
| settings.coverageIstanbulReporter = { | ||
| reports: ['html', 'lcovonly', 'text-summary'], | ||
| dir: './dist/deploy/coverage', | ||
| }; | ||
| } | ||
|
|
||
| config.set(settings); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.