Closed scheung38 closed 4 years ago
ngentest respect the existing tests.
If you want a new test to console, use -F
option.
FYI, currently karma test uses spyOn......
spyOn(component.myForm, 'get').and.returnValue({...
$ gentest -h
Usage: index.js <tsFile> [options]
Options:
--version Show version number [boolean]
-s, --spec write the spec file along with source file [boolean]
-f, --force It prints out a new test file, and it does not ask a
question when overwrite spec file [boolean]
-F, --forcePrint It prints out to console, and it does not ask a question
[boolean]
-m, --method Show code only for this method [string]
-v, --verbose log verbose debug messages [boolean]
--framework test framework, jest or karma [string]
-h Show help [boolean]
Examples:
index.js my.component.ts generate Angular unit test for my.component.ts
$ gentest examples/example2.component.ts --framework=karma -F ...
it('should run #getAmount()', async () => {
component.data = component.data || {};
component.data.amount = 'amount';
component.data.amount2 = 'amount2';
component.selected = component.selected || {};
component.selected.id = 'id';
component.myForm = component.myForm || {};
spyOn(component.myForm, 'get').and.returnValue({
valid: {}
});
component.getAmount();
// expect(component.myForm.get).toHaveBeenCalled();
});
in my project/ngentest.config.js:
Now in project/app/src/my-component:
ngentest my-component.ts
but one of the lines it is still:
and not
?
I simply change from jest to karma in this case?