vendredi 26 août 2016

Qunit _initProperties is not a function

I've run into some strange behavior here and wanted to see if anybody knew why it occurs. I've written a simple Ember QUnit test and want to share some data between each test, just to reduce clutter.

Test

import Ember from 'ember'
import { moduleFor, test } from 'ember-qunit';

let shared = {}
shared.stardardData1 = { id: 1 }
shared.stardardData2 = { id: 2 }

moduleFor('controller:foo', 'description', {
    beforeEach() { ... }
    afterEach() { ... }
}

test('should do things', function () {
    let myGroup = [shared.standardData1, shared.standardData2];
}

A couple things here:

  • I'm getting an error _initProperties is not a function
    • The error goes away when I remove the shared stuff
    • The error persists if I add the shared stuff between the moduleFor and the test
  • I want to be able to share variables defined in either the beforeEach or globally
  • I've tried doing something like let a = 1 in the beforeEach, but can't seem to reference them in the test itself

I noticed that the QUnit docs say that they've eliminated globals. Could that be playing a role in this? http://ift.tt/2bm1W2D

PS: It would be nice to have something that set up the module just once instead of every time




Aucun commentaire:

Enregistrer un commentaire