Giter Site home page Giter Site logo

Comments (2)

markusfalk avatar markusfalk commented on August 22, 2024

I have tried doing that within the test itself but the function adding the class (which is what I wanted to test) gets executed before the html is loaded into qunit-fixture.

the config:

require.config({
    baseUrl: "../",
    paths: {
      'jquery': 'components/bower/jquery/dist/jquery.min',
      'test-foo': 'components/app/foo/test-foo',
      'foo': 'components/app/foo/foo'
    },
    shim: {
     'QUnit': {
        exports: 'QUnit'
      }
    }
});

require(['test-foo'], function(testfoo) {
  testfoo.test();
  QUnit.load();
  QUnit.start();
});

the module

define(['jquery'], function($) {

  'use strict';

  var Foo = {
    _init: function() {
      this._addClass();
    },
    _addClass: function() {
      console.log('adding class testit');
      $('.foo').addClass('testit');
    },
    greet: function() {
      return "Hello";
    }
  };

  Foo._init();

  return {
    greet : Foo.greet
  };

});

the test

define(['foo'], function(foo) {

  'use strict';

  var Test = {
    test: function() {
      module( "module Foo");
      asyncTest("foo class test", function() {
        expect(1);
        // foo() is executed before load is done :(
        $('#qunit-fixture').load('../components/app/foo/foo.html', function(data) {
          ok($('.foo').hasClass('testit'), ".foo should have class 'testit'");
          QUnit.start();
        });
      });
    }
  };

  return {
    test: Test.test
  };

});

from grunt-contrib-qunit.

Arkni avatar Arkni commented on August 22, 2024

I see that you already fixed your problem in above referenced issue.

Closing for now, feel free to ask if you have followup question.

from grunt-contrib-qunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.