File tree Expand file tree Collapse file tree 6 files changed +68
-29
lines changed Expand file tree Collapse file tree 6 files changed +68
-29
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ it('hello world test', () => {
66 expect ( hello ( ) ) . toBe ( 'hello world' ) ;
77} ) ;
88
9+ jest . mock ( 'foo' ) ;
10+
911describe ( 'hello world test' , ( ) => {
10- jest . mock ( 'fs' ) ;
12+ beforeAll ( ( ) => {
13+ jest . mock ( 'foo' ) ;
14+ } ) ;
1115} ) ;
Original file line number Diff line number Diff line change @@ -21,10 +21,29 @@ function transform(sourceText: string) {
2121
2222it ( 'smoke test' , ( ) => {
2323 expect ( lib ) . toBeTruthy ( ) ;
24- expect ( transform ( ';' ) ) . toEqual ( ';' ) ;
24+ expect ( transform ( ';' ) ) . toBe ( ';' ) ;
2525} ) ;
2626
2727it ( 'should be removed it call expression' , ( ) => {
28- debugger ;
29- expect ( transform ( 'it()' ) ) . toEqual ( '' ) ;
28+ expect ( transform ( 'it()' ) ) . toBe ( '' ) ;
29+ expect ( transform ( 'xit()' ) ) . toBe ( '' ) ;
30+ expect ( transform ( 'fit()' ) ) . toBe ( '' ) ;
31+ } ) ;
32+
33+ it ( 'should be removed describe call expression' , ( ) => {
34+ expect ( transform ( 'describe()' ) ) . toBe ( '' ) ;
35+ expect ( transform ( 'xdescribe()' ) ) . toBe ( '' ) ;
36+ expect ( transform ( 'fdescribe()' ) ) . toBe ( '' ) ;
37+ } ) ;
38+
39+ it ( 'functions with modifiers' , ( ) => {
40+ expect ( transform ( 'describe.only()' ) ) . toBe ( '' ) ;
41+ expect ( transform ( 'describe.skip()' ) ) . toBe ( '' ) ;
42+ expect ( transform ( 'describe.any()' ) ) . toBe ( '' ) ;
43+ expect ( transform ( 'test.only()' ) ) . toBe ( '' ) ;
44+ expect ( transform ( 'test.skip()' ) ) . toBe ( '' ) ;
45+ expect ( transform ( 'test.any()' ) ) . toBe ( '' ) ;
46+ expect ( transform ( 'it.only()' ) ) . toBe ( '' ) ;
47+ expect ( transform ( 'it.skip()' ) ) . toBe ( '' ) ;
48+ expect ( transform ( 'it.any()' ) ) . toBe ( '' ) ;
3049} ) ;
Original file line number Diff line number Diff line change @@ -15,10 +15,47 @@ function visitor(node: ts.Node): ts.Node | undefined {
1515 return node ;
1616}
1717
18+ // todo: delete only global
19+ const testMethodList = [
20+ 'jasmine' ,
21+ 'jest' ,
22+ 'before' ,
23+ 'after' ,
24+ 'beforeAll' ,
25+ 'beforeEach' ,
26+ 'afterAll' ,
27+ 'afterEach' ,
28+ 'describe' ,
29+ 'fdescribe' ,
30+ 'xdescribe' ,
31+ 'it' ,
32+ 'fit' ,
33+ 'xit' ,
34+ 'test' ,
35+ 'xtest' ,
36+ 'spyOn' ,
37+ ] ;
38+
39+ function isTestExpressionText ( text : string | ts . __String ) {
40+ return testMethodList . includes ( String ( text ) ) ;
41+ }
42+
1843function isSpecExpressionStatement ( node : ts . Node ) {
19- return ( ts . isExpressionStatement ( node ) && ts . isCallExpression ( node . expression )
20- && ts . isIdentifier ( node . expression . expression )
21- && node . expression . expression . escapedText === 'it' ) ;
44+ if ( ts . isExpressionStatement ( node ) && ts . isCallExpression ( node . expression ) ) {
45+ const callExpr = node . expression . expression ;
46+ if ( ts . isIdentifier ( callExpr ) && isTestExpressionText ( callExpr . escapedText ) ) {
47+ console . log ( "callExpr" , callExpr . flags ) ;
48+ return true ;
49+ }
50+ if ( ts . isPropertyAccessExpression ( callExpr ) ) {
51+ const propertyAccessExpr = callExpr . expression ;
52+ if ( ts . isIdentifier ( propertyAccessExpr ) && isTestExpressionText ( propertyAccessExpr . escapedText ) ) {
53+ console . log ( "propertyAccessExpr" , propertyAccessExpr . flags ) ;
54+ return true ;
55+ }
56+ }
57+ return false ;
58+ }
2259}
2360
2461module . exports = typescriptTransformUnspec ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 4747 "no-reserved-keywords" : false ,
4848 "no-increment-decrement" : false ,
4949 "no-unnecessary-bind" : false ,
50+ "newline-per-chained-call" : false ,
5051 "." : false
5152 }
5253}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments