-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathDebugConfigurationProvider.test.ts
More file actions
52 lines (43 loc) · 2.12 KB
/
DebugConfigurationProvider.test.ts
File metadata and controls
52 lines (43 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
jest.unmock('../src/DebugConfigurationProvider')
import { DebugConfigurationProvider } from '../src/DebugConfigurationProvider'
import { getTestCommand, isCreateReactAppTestCommand } from '../src/helpers'
describe('DebugConfigurationProvider', () => {
it('should by default return a DebugConfiguration for Jest', () => {
const folder: any = { uri: { fsPath: null } }
const sut = new DebugConfigurationProvider()
const configurations = sut.provideDebugConfigurations(folder)
expect(configurations).toHaveLength(1)
const config = configurations[0]
expect(config.name).toBe('vscode-jest-tests')
expect(config.type).toBe('node')
expect(config.args).toContain('--runInBand')
expect(config.program).toMatch('jest')
})
it('should return a valid CRA DebugConfiguration', () => {
;(getTestCommand as jest.Mock<Function>).mockReturnValueOnce('react-scripts test --env=jsdom')
;(isCreateReactAppTestCommand as jest.Mock<Function>).mockReturnValueOnce(true)
const folder: any = { uri: { fsPath: null } }
const sut = new DebugConfigurationProvider()
const configurations = sut.provideDebugConfigurations(folder)
expect(configurations).toHaveLength(1)
const config = configurations[0]
expect(config.name).toBe('vscode-jest-tests')
expect(config.type).toBe('node')
expect(config.runtimeExecutable).toBe('${workspaceFolder}/node_modules/.bin/react-scripts')
expect(config.args[0]).toBe('test')
expect(config.args).toContain('--env=jsdom')
expect(config.args).toContain('--runInBand')
})
it('should append the specified tests', () => {
const fileName = 'fileName'
const testNamePattern = 'testNamePattern'
const expected = [fileName, '--testNamePattern', testNamePattern]
let configuration: any = { name: 'vscode-jest-tests' }
const sut = new DebugConfigurationProvider()
sut.prepareTestRun(fileName, testNamePattern)
configuration = sut.resolveDebugConfiguration(undefined, configuration)
expect(configuration).toBeDefined()
expect(configuration.env && configuration.env.CI).toBeTruthy()
expect(configuration.args).toEqual(expected)
})
})