1.57.0 • Published 4 years ago
@fluffy-spoon/autofake v1.57.0
@fluffy-spoon/autofake
will automatically inject fakes for your constructor arguments. Perfect for quick and easy unit testing!
Example
The following example uses inverse.js
as IOC container.
import Autofaker from '@fluffy-spoon/autofake';
import { Injectable, Inject, Container } from '@fluffy-spoon/inverse';
import InverseProvider from '@fluffy-spoon/autofake-inverse';
const faker = new Autofaker();
const container = new Container();
faker.useInversionOfControlProvider(new InverseProvider(container));
@Injectable
export class Bar {
say() {
return 'hello world';
}
}
@Injectable
export class Foo {
constructor(@Inject public bar: Bar) {
}
doStuff() {
console.log('says', this.bar.say());
}
}
faker.registerFakesForConstructorParameterTypesOf(Foo);
const fakeBar = faker.resolveFakeInstance(Bar);
fakeBar.say().returns('foo');
const realFoo = faker.resolveInstance(Foo);
realFoo.doStuff(); //will execute console.log('says', 'foo')
1.56.0
4 years ago
1.51.0
4 years ago
1.53.0
4 years ago
1.55.0
4 years ago
1.57.0
4 years ago
1.50.0
4 years ago
1.52.0
4 years ago
1.54.0
4 years ago
1.49.0
4 years ago
1.48.0
4 years ago
1.47.0
4 years ago
1.46.0
4 years ago
1.45.0
4 years ago
1.44.0
4 years ago
1.42.0
4 years ago
1.41.0
4 years ago
1.43.0
4 years ago
1.40.0
4 years ago
1.39.0
4 years ago
1.37.0
4 years ago
1.38.0
4 years ago
1.36.0
4 years ago
1.35.0
4 years ago
1.34.0
4 years ago
1.33.0
4 years ago
1.32.0
4 years ago
1.31.0
4 years ago
1.30.0
4 years ago
1.29.0
4 years ago
1.28.0
4 years ago
1.27.0
4 years ago
1.26.0
5 years ago
1.25.0
5 years ago
1.24.0
5 years ago
1.23.0
5 years ago
1.22.0
5 years ago
1.21.0
5 years ago
1.20.0
5 years ago
1.19.0
5 years ago
1.14.0
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.11
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.2
7 years ago