generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

Add an E2E Spec When a View is Created

Open daniellmb opened this issue 12 years ago • 3 comments

I'd suggest adding something like templates/common/e2e.js that would be used in view/index.js that way you'll get it for new routes as well.

describe('<%= name %> page', function () {

  beforeEach(function () {
    browser().navigateTo('/#/<%= name %>');
  });

  it('should have a <%= name %> route configured', function () {
    //shouldn't redirect to the default view
    expect(browser().location().path()).toBe("/<%= name %>");
  });

  it('should render the <%= name %> view when the url is /<%= name %>', function () {
    //check for expected content
    expect(element('[ng-view] p:first').text()).
      toMatch(/This is the <%= name %> view./);
  });

});

daniellmb avatar Aug 19 '13 16:08 daniellmb

it needs a bit more work than that to get the e2e tests to run and the e2e seem to be in a bit of flux state right now. but i agree about the view test

eddiemonge avatar Aug 19 '13 17:08 eddiemonge

I got it working on my fork, with the e2e tests added under a scenarios folder for example e2e/scenarios/routeName.js then you'd have to update the runner file like you do for the index page to add the script tag. But it's setup the way I like using .cshtml view files and C# to automatically bundle the files so I don't have something I can push upstream to you.

It would be really useful to add more customizing via the config. For me I have 98% of it same and just changed a few lines here and there for the view file extensions and some of the templates. For example I could use your code if I could change the view file extension viewFileExt and provide a templatePath to allow overriding the ones I'd like. Here's a few things I changed in my templates:

added yui doc comments enhanced generated specs to include mocks changed indentation to 4 spaces

daniellmb avatar Aug 19 '13 18:08 daniellmb

:+1: e2e testing is really really important. I'll really appreciate this new behavior

BrodaNoel avatar Nov 05 '15 07:11 BrodaNoel