-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transformer): error when running tests with no transformer insta…
…llation
- Loading branch information
Showing
21 changed files
with
103 additions
and
35 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
config/karma/karma.config.base.js → config/karma/base/karma.config.base.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const webpackConfig = require('../../test/noTransformer/webpack.js'); | ||
const karmaBase = require('./karma.config.base'); | ||
|
||
module.exports = function(config, url) { | ||
return karmaBase(config, url, webpackConfig); | ||
}; |
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,6 @@ | ||
const webpackConfig = require('../../test/transformer/webpack.js'); | ||
const karmaBase = require('./karma.config.base'); | ||
|
||
module.exports = function(config, url) { | ||
return karmaBase(config, url, webpackConfig); | ||
}; |
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 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 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 @@ | ||
const karmaBaseConfig = require('./base/karma.config.noTransformer.base'); | ||
|
||
module.exports = function(config) { | ||
const karmaConfig = karmaBaseConfig(config, "../../test/noTransformer/**/*.test.ts"); | ||
|
||
config.set(karmaConfig); | ||
}; |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../webpack.base.js'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require('path'); | ||
|
||
module.exports = function () { | ||
return { | ||
mode: "development", | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
alias: { | ||
['ts-auto-mock']: path.join(__dirname, '../../dist'), | ||
['ts-auto-mock/repository']: path.join(__dirname, '../../dist/repository'), | ||
['ts-auto-mock/extension']: path.join(__dirname, '../../dist/extension'), | ||
} | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
enforce: 'pre', | ||
loader: 'eslint-loader' | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
loader: 'awesome-typescript-loader' | ||
} | ||
] | ||
} | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
import { DeepPartial } from './partial/deepPartial'; | ||
export declare function createMockList<T extends object>(quantity: number, iterator?: (index: number) => DeepPartial<T>): T[]; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function createMockList<T extends object>(quantity: number, iterator?: (index: number) => DeepPartial<T>): T[] { | ||
throw new Error(` | ||
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation | ||
If help is required you can find us on https://typescript-tdd.github.io | ||
`); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import { DeepPartial } from './partial/deepPartial'; | ||
|
||
export declare function createMock<T extends object>(values?: DeepPartial<T>): T; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function createMock<T extends object>(values?: DeepPartial<T>): T { | ||
throw new Error(` | ||
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation | ||
If help is required you can find us on https://typescript-tdd.github.io | ||
`); | ||
} |
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
export declare function registerMock<T extends object>(factory: () => T): void; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function registerMock<T extends object>(factory: () => T): void { | ||
throw new Error(` | ||
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation | ||
If help is required you can find us on https://typescript-tdd.github.io | ||
`); | ||
} |
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,14 @@ | ||
import { createMock, createMockList, registerMock } from 'ts-auto-mock'; | ||
|
||
interface MyInterface { | ||
a: string; | ||
b: number; | ||
} | ||
|
||
describe('when using placeholder functions without installing the transformer', () => { | ||
it('should throw an error linking the installation guide', () => { | ||
expect(() => createMock<MyInterface>()).toThrowError(/https:\/\/typescript-tdd.github.io\/ts-auto-mock\/installation/); | ||
expect(() => createMockList<MyInterface>(2)).toThrowError(/https:\/\/typescript-tdd.github.io\/ts-auto-mock\/installation/); | ||
expect(() => registerMock<MyInterface>(() => ({ a: '', b: 4 }))).toThrowError(/https:\/\/typescript-tdd.github.io\/ts-auto-mock\/installation/); | ||
}); | ||
}); |