kaliber5 / ember-cli-yadda

Write cucumber specs for ember-cli applications
MIT License
42 stars 22 forks source link

Incorrect scope in steps #76

Open lukeclewlow opened 6 years ago

lukeclewlow commented 6 years ago

Hi there,

I've recently upgraded a project to the new testing format, and followed the instructions in the README, however, the scope of this inside my step file is wrong as it does not have a this.element as the docs suggest it should.

Below is a simplified version of my steps file, have put it all in steps.js for brevity.

// steps.js
import { visit, click, currentURL } from '@ember/test-helpers';
import yadda from '../../helpers/yadda';

export default function(assert) {
  return yadda.localisation.default.library()
  .given('I am on the dashboard', async function() {
    await visit('/');
  })
  .when('I click the learning link', async function() {
    await click('a.learning');
  })
  .then('I should see a list of learning activities', async function() {
    // this.element is undefined here
    assert.equal(this.element.querySelector('ul.posts li').textContent, 'My new post');
  })
}

I'm not sure if some of my setup is wrong or if this is a bug. Any help greatly appreciated.

Thanks!

simonihmig commented 6 years ago

@lukeclewlow sorry for the late response here! Have you added the @setupApplicationTest annotation?