Skip to content

Commit 7084800

Browse files
authored
test(inline-suggestion): crossFileContextUtil.test using real clock and test timeouts #6258
## Problem ref #6252 Test is using real system clock, it's likely to timeout due to heavy computation in an undeterministic way. ## Solution Use fake clock.
1 parent 4a0187d commit 7084800

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/amazonq/test/unit/codewhisperer/util/crossFileContextUtil.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
*/
55

66
import assert from 'assert'
7+
import * as FakeTimers from '@sinonjs/fake-timers'
78
import * as vscode from 'vscode'
89
import * as sinon from 'sinon'
910
import * as crossFile from 'aws-core-vscode/codewhisperer'
10-
import { aStringWithLineCount, createMockTextEditor } from 'aws-core-vscode/test'
11+
import { aStringWithLineCount, createMockTextEditor, installFakeClock } from 'aws-core-vscode/test'
1112
import { FeatureConfigProvider, crossFileContextConfig } from 'aws-core-vscode/codewhisperer'
1213
import {
1314
assertTabCount,
@@ -30,6 +31,15 @@ describe('crossFileContextUtil', function () {
3031
}
3132

3233
let mockEditor: vscode.TextEditor
34+
let clock: FakeTimers.InstalledClock
35+
36+
before(function () {
37+
clock = installFakeClock()
38+
})
39+
40+
after(function () {
41+
clock.uninstall()
42+
})
3343

3444
afterEach(function () {
3545
sinon.restore()
@@ -312,9 +322,7 @@ describe('crossFileContextUtil', function () {
312322
})
313323

314324
describe('full support', function () {
315-
// TODO: fix it
316-
// const fileExtLists = ['java', 'js', 'ts', 'py', 'tsx', 'jsx']
317-
const fileExtLists = ['java']
325+
const fileExtLists = ['java', 'js', 'ts', 'py', 'tsx', 'jsx']
318326

319327
before(async function () {
320328
this.timeout(60000)

0 commit comments

Comments
 (0)