Skip to content

Commit 5e39997

Browse files
committed
several thousand lines of test typing
1 parent 15fe344 commit 5e39997

Some content is hidden

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

47 files changed

+1213
-603
lines changed

jest.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
module.exports = {
2-
testURL: 'http://localhost/index.html',
2+
globals: {
3+
'ts-jest': {
4+
tsConfig: 'tsconfig.base.json',
5+
},
6+
},
7+
testEnvironment: 'jsdom',
8+
testEnvironmentOptions: {
9+
url: 'http://localhost/index.html',
10+
},
311
moduleNameMapper: {
412
'^.+\\.(css|scss)$': 'identity-obj-proxy',
513
},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"identity-obj-proxy": "^3.0.0",
6363
"jest": "^29.5.0",
6464
"jest-cli": "^29.5.0",
65+
"jest-environment-jsdom": "^29.5.0",
6566
"npm-run-all": "^4.1.5",
6667
"npm-run-bg": "^1.0.7",
6768
"prettier": "^2.6.0",

packages/browser-info/__tests__/chrome.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ describe('chrome browser info', () => {
5151
try {
5252
await getBrowserInfo(ChromeChannel.stable)
5353
} catch (err) {
54-
// @ts-expect-error
5554
expect(err.message).toBe('Unable to find Chrome installation')
5655
}
5756
})
@@ -154,7 +153,6 @@ describe('chrome browser info', () => {
154153
try {
155154
await getBrowserInfo(ChromeChannel.stable)
156155
} catch (err) {
157-
// @ts-expect-error
158156
expect(err.message).toBe('Unable to find Chrome installation')
159157
}
160158
})
@@ -163,7 +161,6 @@ describe('chrome browser info', () => {
163161
try {
164162
await getBrowserInfo(ChromeChannel.canary)
165163
} catch (err) {
166-
// @ts-expect-error
167164
expect(err.message).toBe('Unsupported channel canary')
168165
}
169166
})

packages/browser-info/__tests__/sh.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ describe('sh', () => {
4242
'console.log(`out`);console.error(`err`);process.exit(1);',
4343
])
4444
} catch (err) {
45-
// @ts-expect-error
4645
expect(err.stdout).toBe('out\n')
47-
// @ts-expect-error
4846
expect(err.stderr).toBe('err\n')
49-
// @ts-expect-error
5047
expect(err.code).toBe(1)
5148
}
5249
})
@@ -55,7 +52,6 @@ describe('sh', () => {
5552
try {
5653
await sh('command-that-does-not-exist')
5754
} catch (err) {
58-
// @ts-expect-error
5955
expect(err.code).toBe(1)
6056
}
6157
})

packages/browser-info/jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
testEnvironmentOptions: {
4+
url: 'http://localhost/index.html',
5+
},
6+
moduleNameMapper: {
7+
'^.+\\.(css|scss)$': 'identity-obj-proxy',
8+
},
9+
setupFilesAfterEnv: ['./scripts/jest/test.config.js'],
10+
testMatch: ['**/packages/**/__test?(s)__/**/*.spec.[jt]s?(x)'],
11+
testPathIgnorePatterns: ['/node_modules/'],
12+
transform: {
13+
'^.+\\.jsx?$': 'babel-jest',
14+
'^.+\\.tsx?$': 'ts-jest',
15+
},
16+
}

packages/get-driver/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"strictNullChecks": true
88
},
99
"include": ["src/**/*.ts"],
10-
"exclude": ["**/__mocks__", "**/__tests__"]
10+
"exclude": ["**/__mocks__"]
1111
}

packages/side-api/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outDir": "dist"
77
},
88
"include": ["src/**/*.ts"],
9-
"exclude": ["**/__mocks__", "**/__tests__"],
9+
"exclude": ["**/__mocks__"],
1010
"references": [
1111
{
1212
"path": "../browser-info"

packages/side-code-export/__test__/src/code-export/emit.spec.js renamed to packages/side-code-export/__test__/src/code-export/emit.spec.ts.skip

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
emitLocation,
2121
emitSelection,
2222
emitOriginTracing,
23+
SelectionEmitters,
2324
} from '../../../src/code-export/emit'
2425
import TestCase from '../../../../selenium-ide/src/neo/models/TestCase'
2526
import Command from '../../../../selenium-ide/src/neo/models/Command'
@@ -76,15 +77,15 @@ describe('Command emitter', () => {
7677
describe('Location emitter', () => {
7778
it('emits by sync emitter', () => {
7879
const emitters = {
79-
id: selector => {
80+
id: (selector) => {
8081
return `By.id("${selector}")`
8182
},
8283
}
8384
expect(emitLocation('id=blah', emitters)).toEqual(`By.id("blah")`)
8485
})
8586
it('emits by async emitter', () => {
8687
const emitters = {
87-
id: selector => {
88+
id: (selector) => {
8889
return Promise.resolve(`By.id("${selector}")`)
8990
},
9091
}
@@ -103,20 +104,20 @@ describe('Location emitter', () => {
103104
describe('Selection emitter', () => {
104105
it('emits by sync emitter', () => {
105106
const emitters = {
106-
id: id => {
107+
id: (id) => {
107108
return `By.css(\`*[id="${id}"]\`)`
108109
},
109-
}
110+
} as unknown as SelectionEmitters
110111
expect(emitSelection('id=blah', emitters)).toEqual(
111112
`By.css(\`*[id="blah"]\`)`
112113
)
113114
})
114115
it('emits by async emitter', () => {
115116
const emitters = {
116-
id: id => {
117+
id: (id) => {
117118
return Promise.resolve(`By.css(\`*[id="${id}"]\`)`)
118119
},
119-
}
120+
} as unknown as SelectionEmitters
120121
expect(emitSelection('id=blah', emitters)).resolves.toBe(
121122
`By.css(\`*[id="blah"]\`)`
122123
)
@@ -138,25 +139,27 @@ describe('Trace emitter', () => {
138139
const test = new TestCase()
139140
test.createCommand(undefined, 'a', 'foo', 'bar')
140141
test.createCommand(undefined, 'b', 'baz', 'qux', 'a comment')
141-
expect(emitOriginTracing(test, { commentPrefix: '//' }, true, false)).toEqual([
142+
expect(
143+
emitOriginTracing(test, { commentPrefix: '//' }, true, false)
144+
).toEqual([
142145
'// Test name: Untitled Test',
143146
'// Step # | name | target | value | comment',
144147
'// 1 | a | foo | bar | ',
145148
'// 2 | b | baz | qux | a comment',
146149
])
147-
expect(emitOriginTracing(test, { commentPrefix: '//' }, true, true)).toEqual([
150+
expect(
151+
emitOriginTracing(test, { commentPrefix: '//' }, true, true)
152+
).toEqual([
148153
'// Test name: Untitled Test',
149154
'// Step # | name | target | value',
150155
'// 1 | a | foo | bar',
151156
'// 2 | b | baz | qux\n// a comment',
152157
])
153-
expect(emitOriginTracing(test, { commentPrefix: '//' }, false, true)).toEqual([
154-
'',
155-
'// a comment',
156-
])
157-
expect(emitOriginTracing(test, { commentPrefix: '//' }, false, false)).toEqual([
158-
'',
159-
'',
160-
])
158+
expect(
159+
emitOriginTracing(test, { commentPrefix: '//' }, false, true)
160+
).toEqual(['', '// a comment'])
161+
expect(
162+
emitOriginTracing(test, { commentPrefix: '//' }, false, false)
163+
).toEqual(['', ''])
161164
})
162165
})

packages/side-code-export/__test__/src/code-export/hook.spec.js renamed to packages/side-code-export/__test__/src/code-export/hook.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
import Hook from '../../../src/code-export/hook'
19+
import { ExportCommandsShape } from '../../../src/types'
1920

2021
describe('Hooks', () => {
2122
it('should clear registered commands', () => {
@@ -28,7 +29,7 @@ describe('Hooks', () => {
2829
})
2930
it('should not error when no emitters registered', async () => {
3031
const hook = new Hook()
31-
const result = await hook.emit()
32+
const result = (await hook.emit({})) as ExportCommandsShape
3233
expect(result.commands).toEqual([])
3334
})
3435
it('should emit command object', () => {
@@ -37,8 +38,8 @@ describe('Hooks', () => {
3738
endingSyntax: 'blah99',
3839
registrationLevel: 1,
3940
})
40-
hook.register(() => {
41-
return Promise.resolve('blah2')
41+
hook.register(async () => {
42+
return await 'blah2'
4243
})
4344
hook.register(() => {
4445
return 'blah3'
@@ -81,10 +82,10 @@ describe('Hooks', () => {
8182
return 'blah'
8283
})
8384
hook.register(() => {
84-
return 1234
85+
return '1234'
8586
})
8687
expect(hook.isRegistered('blah')).resolves.toBeTruthy()
87-
expect(hook.isRegistered(1234)).resolves.toBeTruthy()
88+
expect(hook.isRegistered('1234')).resolves.toBeTruthy()
8889
expect(hook.isRegistered('halb')).resolves.toBeFalsy()
8990
})
9091
})

0 commit comments

Comments
 (0)