Test tip! Whenever you instantiate our YUI App object in tests, please do three things:

  • Instantiate it with a mock connection if you need it, or with a super simple stub. You can use the env attribute for that, or a new conn attribute, like this:

    conn: {close: function() {}}

    Why? It prevents extra code running after your test is done, hosing our test run intermittently. Like, say, for instance, in CI.
  • after instantiating an app object, unless you are explicitly testing dispatch or something that happens after dispatch, register a no-op view, like this:

    app.showView(new Y.View());

    Why? Same reason.
  • In afterEach, destroy your new app.

    Why? Same reason.

  • Advertisements