Search code examples
angularjsyeomanyeoman-generatorangularjs-e2eyeoman-generator-angular

'test/spec/**/*.' + jsExt in Yeoman generator-angular


Hi I just have a question:

What exactly does 'test/mock/**/*.' + jsExt do?

I know 'test/spec/**/*.' + jsExt is to unit test controllers.

I thought this was for e2e test but I learned it is not integrated yet.

It might be better if we include a sample file in test/spec/ folder?

Also this might be a silly question. Since there is no e2e integrated, why does the generator include 'angular-scenario' by default? Is it just for people who want to add e2e test in their project?

Thank you.

commit log is https://github.com/yeoman/generator-angular/commit/0f768f1d7515b3d884555a8c5c8e3f01d117cf18#commitcomment-6826108


Solution

  • This is where you put your mocks.

    So for example, let's say you typically make a $http call to get a value from the server. During unit testing you don't want to do this, you want to mock this out.

    You can do that with the $q library and return a 'mocked' value. Then instead of injecting the service that has the $http call, you would inject the server that uses $q and returns the mocked value.

    Hope this helps.