Skip to content

Commit 7a4ee21

Browse files
doniyor2109SimenB
authored andcommitted
Jest jasmine/ts migration (#7970)
1 parent d23f1ef commit 7a4ee21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2331
-1911
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
### Chore & Maintenance
3939

40+
- `[jest-jasmine2]`: TS migration ([#7970](https://github.com/facebook/jest/pull/7970))
4041
- `[jest-each]`: Refactor into multiple files with better types ([#8018](https://github.com/facebook/jest/pull/8018))
4142
- `[jest-each]`: Migrate to Typescript ([#8007](https://github.com/facebook/jest/pull/8007))
4243
- `[jest-environment-jsdom]`: Migrate to TypeScript ([#7985](https://github.com/facebook/jest/pull/8003))

packages/jest-jasmine2/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@
88
},
99
"license": "MIT",
1010
"main": "build/index.js",
11+
"types": "build/index.d.ts",
1112
"dependencies": {
1213
"@babel/traverse": "^7.1.0",
14+
"@jest/environment": "^24.1.0",
15+
"@jest/types": "^24.1.0",
1316
"chalk": "^2.0.1",
1417
"co": "^4.6.0",
1518
"expect": "^24.1.0",
1619
"is-generator-fn": "^2.0.0",
1720
"jest-each": "^24.0.0",
1821
"jest-matcher-utils": "^24.0.0",
1922
"jest-message-util": "^24.0.0",
23+
"jest-runtime": "^24.1.0",
2024
"jest-snapshot": "^24.1.0",
2125
"jest-util": "^24.0.0",
2226
"pretty-format": "^24.0.0",
2327
"throat": "^4.0.0"
2428
},
2529
"devDependencies": {
26-
"@types/babel__traverse": "^7.0.4",
27-
"jest-diff": "^24.0.0",
28-
"jest-runtime": "^24.1.0"
30+
"@types/babel__traverse": "^7.0.4"
2931
},
3032
"engines": {
3133
"node": ">= 6"

packages/jest-jasmine2/src/ExpectationFailed.js renamed to packages/jest-jasmine2/src/ExpectationFailed.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @flow
86
*/
97

108
export default class ExpectationFailed extends Error {}

packages/jest-jasmine2/src/PCancelable.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
27

38
'use strict';
49

packages/jest-jasmine2/src/__tests__/Suite.test.js renamed to packages/jest-jasmine2/src/__tests__/Suite.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
*
77
*/
88

9-
'use strict';
10-
11-
import Suite from '../jasmine/Suite';
9+
import Suite, {Attributes} from '../jasmine/Suite';
1210

1311
describe('Suite', () => {
14-
let suite;
12+
let suite: Suite;
1513

1614
beforeEach(() => {
1715
suite = new Suite({
1816
getTestPath: () => '',
19-
});
17+
} as Attributes);
2018
});
2119

2220
it("doesn't throw on addExpectationResult when there are no children", () => {
2321
expect(() => {
22+
// @ts-ignore
2423
suite.addExpectationResult();
2524
}).not.toThrow();
2625
});

packages/jest-jasmine2/src/__tests__/expectationResultFactory.test.js renamed to packages/jest-jasmine2/src/__tests__/expectationResultFactory.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*
77
*/
88

9-
'use strict';
10-
119
import expectationResultFactory from '../expectationResultFactory';
1210

1311
describe('expectationResultFactory', () => {

packages/jest-jasmine2/src/__tests__/hooksError.test.js renamed to packages/jest-jasmine2/src/__tests__/hooksError.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @flow
86
*/
97

10-
'use strict';
8+
export type SharedHookType = 'afterAll' | 'beforeAll';
9+
export type HookType = SharedHookType | 'afterEach' | 'beforeEach';
1110

1211
describe.each([['beforeEach'], ['beforeAll'], ['afterEach'], ['afterAll']])(
1312
'%s hooks error throwing',
14-
fn => {
13+
(fn: HookType) => {
1514
test.each([
1615
['String'],
1716
[1],

packages/jest-jasmine2/src/__tests__/itTestError.test.js renamed to packages/jest-jasmine2/src/__tests__/itTestError.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*
77
*/
88

9-
'use strict';
10-
119
describe('test/it error throwing', () => {
1210
it(`it throws error with missing callback function`, () => {
1311
expect(() => {
@@ -18,11 +16,13 @@ describe('test/it error throwing', () => {
1816
});
1917
it(`it throws an error when first argument isn't a string`, () => {
2018
expect(() => {
19+
// @ts-ignore
2120
it(() => {});
2221
}).toThrowError(`Invalid first argument, () => {}. It must be a string.`);
2322
});
2423
it('it throws an error when callback function is not a function', () => {
2524
expect(() => {
25+
// @ts-ignore
2626
it('test3', 'test3b');
2727
}).toThrowError(
2828
'Invalid second argument, test3b. It must be a callback function.',
@@ -37,11 +37,13 @@ describe('test/it error throwing', () => {
3737
});
3838
test(`test throws an error when first argument isn't a string`, () => {
3939
expect(() => {
40+
// @ts-ignore
4041
test(() => {});
4142
}).toThrowError(`Invalid first argument, () => {}. It must be a string.`);
4243
});
4344
test('test throws an error when callback function is not a function', () => {
4445
expect(() => {
46+
// @ts-ignore
4547
test('test6', 'test6b');
4648
}).toThrowError(
4749
'Invalid second argument, test6b. It must be a callback function.',

0 commit comments

Comments
 (0)