Skip to content

Commit dd73b57

Browse files
committed
feat(transformer): extract repeated error in a constant, fixed error wording
1 parent 16506e5 commit dd73b57

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/create-mock-list.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import { NoTransformerError } from './errors/no-transformer.error';
12
import { DeepPartial } from './partial/deepPartial';
23

34
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45
export function createMockList<T extends object>(quantity: number, iterator?: (index: number) => DeepPartial<T>): T[] {
5-
throw new Error(`
6-
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation
7-
If help is required you can find us on https://typescript-tdd.github.io
8-
`);
6+
throw new Error(NoTransformerError);
97
}

src/create-mock.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import { NoTransformerError } from './errors/no-transformer.error';
12
import { DeepPartial } from './partial/deepPartial';
23

34
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45
export function createMock<T extends object>(values?: DeepPartial<T>): T {
5-
throw new Error(`
6-
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation
7-
If help is required you can find us on https://typescript-tdd.github.io
8-
`);
6+
throw new Error(NoTransformerError);
97
}

src/errors/no-transformer.error.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const NoTransformerError: string = `
2+
hey, it looks like ts-auto-mock is not configured correctly! You can find the instructions here https://typescript-tdd.github.io/ts-auto-mock/installation.
3+
If you need further assistance feel free to drop a message on slack. (link at the bottom of https://typescript-tdd.github.io/ts-auto-mock)
4+
`;

src/register-mock.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { NoTransformerError } from './errors/no-transformer.error';
2+
13
// eslint-disable-next-line @typescript-eslint/no-unused-vars
24
export function registerMock<T extends object>(factory: () => T): void {
3-
throw new Error(`
4-
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation
5-
If help is required you can find us on https://typescript-tdd.github.io
6-
`);
5+
throw new Error(NoTransformerError);
76
}

0 commit comments

Comments
 (0)