-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted tests to typescript with jest
- Loading branch information
1 parent
2fb0f37
commit 2dac2ee
Showing
20 changed files
with
3,136 additions
and
808 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ["**/src/test/*.test.ts"], | ||
testTimeout: 30000, | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'fs-extra'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { join } from 'path'; | ||
import { TscWatchClient } from '../client'; | ||
import { | ||
copyFixtures, | ||
FAILING_FILE, | ||
OUTPUT_FILE, | ||
PASSING_FILE, | ||
removeFixtures, | ||
waitFor, | ||
} from './test-utils'; | ||
|
||
describe('Client Events', () => { | ||
let watchClient: TscWatchClient; | ||
let callback: jest.Mock; | ||
|
||
beforeEach(() => { | ||
const tscWatchPath = require.resolve(join('..', '..', 'dist', 'lib', 'tsc-watch')); | ||
watchClient = new TscWatchClient(tscWatchPath); | ||
callback = jest.fn(); | ||
copyFixtures(); | ||
}); | ||
|
||
afterEach(() => { | ||
watchClient.kill(); | ||
removeFixtures(); | ||
}); | ||
|
||
describe('Events', () => { | ||
it('Should emit "started" on compilation start', () => { | ||
watchClient.on('started', callback); | ||
watchClient.start('--noClear', '--out', OUTPUT_FILE, FAILING_FILE); | ||
return waitFor(() => callback.mock.calls.length > 0); | ||
}); | ||
|
||
it('Should emit "first_success" on first success', async () => { | ||
watchClient.on('first_success', callback); | ||
watchClient.start('--noClear', '--out', OUTPUT_FILE, PASSING_FILE); | ||
return waitFor(() => callback.mock.calls.length > 0); | ||
}); | ||
|
||
it('Should emit "success" on first success', async () => { | ||
watchClient.on('success', callback); | ||
watchClient.start('--noClear', '--out', OUTPUT_FILE, PASSING_FILE); | ||
return waitFor(() => callback.mock.calls.length > 0); | ||
}); | ||
|
||
it('Should deserialize and emit a "file_emitted" with the emitted file path', async function () { | ||
watchClient.on('file_emitted', callback); | ||
watchClient.start('--noClear', '--listEmittedFiles', '--out', OUTPUT_FILE, PASSING_FILE); | ||
return waitFor(() => { | ||
if (callback.mock.calls.length > 0) { | ||
const firstCall = callback.mock.calls[0]; | ||
const callFirstArg = firstCall[0]; | ||
return callFirstArg === OUTPUT_FILE; | ||
} | ||
}); | ||
}); | ||
|
||
it('Should fire "compile_errors" on when tsc compile errors occur', async () => { | ||
watchClient.on('compile_errors', callback); | ||
watchClient.start('--noClear', '--out', OUTPUT_FILE, FAILING_FILE); | ||
return waitFor(() => callback.mock.calls.length > 0); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.