Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test pass only if singleRun is false #138

Open
manuelmazzuola opened this issue Apr 27, 2017 · 1 comment
Open

Test pass only if singleRun is false #138

manuelmazzuola opened this issue Apr 27, 2017 · 1 comment

Comments

@manuelmazzuola
Copy link

manuelmazzuola commented Apr 27, 2017

I'm experiencing an issue where this test pass only if singleRun is false.
When I set singleRun to true the test fails because template.html() is empty.
I've tried to add timeouts or to fire more digests but it always fails.
It seems that the template of my-app-language-switcher (it uses templateUrl) is not correctly loaded and the directive is not compiled if singleRun is true: I've tried to console.log the document.body after the digest and the directive is not compiled.

-- karma conf file
ngHtml2JsPreprocessor: {
  moduleName: 'templates',
  stripPrefix: 'app/',
},
preprocessors: {
  'test/unit/**/*.js': ['babel'],
  'app/views/directive/*.html': ['ng-html2js']
},
files: [
  'test/res/inject-raven.js',
  'app_babel/scripts/**/*.js',
  'app/views/directive/*.html',
  'test/unit/**/*.js'
]

-- test
describe('Language switcher suite', () => {
  let $compile, $scope;

  beforeEach(angular.mock.module('myApp'));
  beforeEach(angular.mock.module('templates'));

  beforeEach(inject((_$compile_, _$rootScope_) => {
    $compile = _$compile_;
    $scope = _$rootScope_.$new();
  }));

  it('Should show the language switcher', () => {
    // pending();
    const template = $compile('<my-app-language-switcher />')($scope);
    document.body.appendChild(template[0]);
    $scope.$digest();
    expect(template.html()).toContain('flag-icon-gb');
  });
});
@manuelmazzuola manuelmazzuola changed the title Test pass only is singleRun is false Test pass only if singleRun is false Apr 27, 2017
@manuelmazzuola
Copy link
Author

It works if I use singleRun true and Chrome as the browser.
The test fails if it runs on phantomjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant