question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation needed for new module-for-acceptance

See original GitHub issue

Before ember v3 we had module-for-acceptance file, in it I could declare default beforeEach and afterEach hooks for all my application tests:

import QUnit from 'qunit';
import { resolve } from 'rsvp';
import startApp from '../helpers/start-app';
import destroyApp from './destroy-app';

export default function(name, options = {}) {
  QUnit.module(name, {
    beforeEach() {
      window.localStorage.clear();
      Object.keys(window.Cookies.get()).forEach((cookieName) => window.Cookies.remove(cookieName));

      this.application = startApp();

      if (options.beforeEach) {
        return options.beforeEach.apply(this, arguments);
      }
    },

    afterEach() {
      window.localStorage.clear();
      Object.keys(window.Cookies.get()).forEach((cookieName) => window.Cookies.remove(cookieName));

      let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
      return resolve(afterEach).then(() => destroyApp(this.application));
    }
  });
}

now we dont have such functionality so I dont know how to extend setupApplicationTest(hooks), with cache clears.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
backspacecommented, Aug 13, 2018

@sbrichards, I was able to accomplish this just now by adding tests/helpers/setup-application-test.js with my previous destroy-app code:

import { setupApplicationTest } from 'ember-qunit';

export default function(hooks) {
  setupApplicationTest(hooks);

  hooks.afterEach(function() {
    localStorage.removeItem('person-token');
    …
  });
}

Then instead of importing setupApplicationTest from ember-qunit in each test file, I import my overridden version.

1reaction
izelnakricommented, Mar 12, 2018

yes this is not a global module extension, I already used these. The issue is some of my hooks are very repetitive when I write them for every module. module-for-acceptance.js used to replace QUnit module() with predefined beforeEach, afterEach logic. Could we reopen this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Acceptance Tests - Ember Guides
moduleForAcceptance deals with application setup and teardown. The last few lines, within the function test , contain an example test.
Read more >
Modules And Helpers - Codeception Docs
There is the WebDriver module for acceptance testing, modules for all popular PHP frameworks, PHPBrowser to emulate browser execution, REST for testing APIs ......
Read more >
Force Development and Documentation Consolidated ...
Basis of issue plans are requirements documents. BOIPs support equipment acquisition and materiel development by identifying and documenting ...
Read more >
How to use a service from an acceptance test in Ember.js
import moduleForAcceptance from 'super-rentals/tests/helpers/module-for-acceptance'; import Service from '@ember/service';
Read more >
Test helpers - Ember Power Select
To use those helpers in acceptance tests that use moduleForAcceptance , you need to ... However if you are using the new testing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found