Issue
I have my angular app, declared like this:
app.module.ts
export class AppModule {}
for which I can run tests with ng test MyApp
Within this app, I have multiple modules, declared like this:
my-one.module.ts / my-other.module.ts
export class MyOneModule {}
export class MyOtherModule {}
These are imported in AppModule.
How can I do something like ng test MyOneModule
/ ng test MyOtherModule
, with which I'd like to run just the tests of all components in that very "sub module" instead of all tests in the app?
I couldn't find information in the official docu or here in StackOverflow. Is it possible at all?
Solution
I ended up using this workaround:
In test.ts
I change the path:
const context: any = require.context('./', true, /\.spec\.ts$/);
to
const context: any = require.context('./app/modules/my-one-module', true, /\.spec\.ts$/);
or
const context: any = require.context('./app/modules/my-other-module', true, /\.spec\.ts$/);
This causes ng test
to just execute the tests in the defined directory (and its sub directories).
Not ideal, as I don't like to make changes to checked-in files, that are not meant to be committed, but it does the job.
Answered By - jasie
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.