File tree Expand file tree Collapse file tree
built-in-plugins/command-test/plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export const runTest = async (options: IOpts) => {
4141 ) ,
4242 } ;
4343
44- await jest . runCLI (
44+ const result = await jest . runCLI (
4545 {
4646 _ : options . _ ,
4747 $0 : options . $0 ,
@@ -50,9 +50,11 @@ export const runTest = async (options: IOpts) => {
5050 [ pri . projectRootPath ] ,
5151 ) ;
5252
53- logText (
54- `Open this url to see code coverage: file://${ path . join ( pri . projectRootPath , 'coverage/lcov-report/index.html' ) } ` ,
55- ) ;
53+ plugin . afterTestRunCallbacks . forEach ( callback => {
54+ return callback ( result ) ;
55+ } ) ;
56+
57+ logText ( `Open this url to see code coverage: file://${ path . join ( pri . sourceRoot , 'coverage/lcov-report/index.html' ) } ` ) ;
5658
5759 process . exit ( 0 ) ;
5860} ;
Original file line number Diff line number Diff line change 11import { plugin } from '../utils/plugins' ;
2- import { IJestConfigPipe } from '../utils/define' ;
2+ import { IJestConfigPipe , IAfterTestRun } from '../utils/define' ;
33
44export const pipeJestConfig = ( pipe : IJestConfigPipe ) => {
55 plugin . jestConfigPipes . push ( pipe ) ;
66} ;
7+
8+ export const afterTestRun = ( callback : IAfterTestRun ) => {
9+ plugin . afterTestRunCallbacks . push ( callback ) ;
10+ } ;
Original file line number Diff line number Diff line change @@ -394,3 +394,5 @@ export interface IPluginModule {
394394export type IDevDllList = ( list : string [ ] ) => string [ ] ;
395395
396396export type IJestConfigPipe = ( options : any ) => any ;
397+
398+ export type IAfterTestRun = ( result ?: any ) => any ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
2121 ProjectType ,
2222 IDevDllList ,
2323 IJestConfigPipe ,
24+ IAfterTestRun ,
2425} from './define' ;
2526import { getBabelOptions } from './babel-options' ;
2627import { tempPath , srcPath } from '../node' ;
@@ -95,6 +96,8 @@ export class IPluginConfig {
9596
9697 public jestConfigPipes : IJestConfigPipe [ ] = [ ] ;
9798
99+ public afterTestRunCallbacks : IAfterTestRun [ ] = [ ] ;
100+
98101 // Lock init type
99102 public initType : ProjectType = null ;
100103}
You can’t perform that action at this time.
0 commit comments