Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeEach nested in a loop is not converted #51

Open
apellerano-pw opened this issue Oct 8, 2018 · 1 comment
Open

beforeEach nested in a loop is not converted #51

apellerano-pw opened this issue Oct 8, 2018 · 1 comment

Comments

@apellerano-pw
Copy link

input:

import { expect } from 'chai';
import { beforeEach, describe, it } from 'mocha';
import { setupComponentTest } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';

describe('Integration | Component | foo', function () {
  setupComponentTest('foo', { integration: true });
  [true, false].forEach((blah) => {
    beforeEach(function () {
      this.set('blah', blah);
      this.render(hbs`{{foo bar=blah}}`);
    });
    it('should do the thing', function () {
      expect(true).to.be.true;
    });
  });
});

expected output: the this.render in beforeEach is converted to an await render and function made async.

actual output:

import { expect } from 'chai';
import { beforeEach, describe, it } from 'mocha';
import { setupRenderingTest } from 'ember-mocha';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

describe('Integration | Component | foo', function () {
  setupRenderingTest();
  [true, false].forEach((blah) => {
    beforeEach(function () {
      this.set('blah', blah);
      render(hbs`{{foo bar=blah}}`);
    });
    it('should do the thing', function () {
      expect(true).to.be.true;
    });
  });
});

The async/await part seems to be what messes up

@apellerano-pw apellerano-pw changed the title nested beforeEach not converted beforeEach nested in a loop is not converted Oct 8, 2018
@Turbo87
Copy link
Collaborator

Turbo87 commented Oct 8, 2018

The problem is most likely the forEach call here. We only convert those hooks inside describe blocks because we can't be sure that the other thing would be correct without actually evaluating the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants