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

Adding nested test failing testcase #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alexander-alvarez
Copy link
Contributor

No description provided.

@rwjblue
Copy link
Member

rwjblue commented Nov 14, 2017

Hmm. I'm not quite sure how best to fix this. We intentionally only run on expressions in the root of the program body (so that we don't accidentally convert test() invocations that are not supposed to be transformed).

@alexander-alvarez
Copy link
Contributor Author

Conceptually, could we not trace the lineage of the test function block in the AST to an allowed module, and use that to transform the test blocks?

@rwjblue
Copy link
Member

rwjblue commented Nov 14, 2017

could we not trace the lineage of the test function block in the AST to an allowed module, and use that to transform the test blocks

I don't think we can know for certain 🤔

Consider this:

moduleForComponent('whatever', { integration: true });

// these should get transformed
test(...);
test(...);

export function generateTests() {
  // how do we attribute these?
  test(...);
  test(...);
  test(...);
}

@alexander-alvarez
Copy link
Contributor Author

To be transformed generateTests would have to be invoked in the context of module?

// my-test-helper.js
export function generateTests() {
  test(...);
  test(...);
  test(...);
}
import { generateTests } from './my-test-helper';

moduleForComponent('whatever', { integration: true });

// these should get transformed
test(...);
test(...);

// I guess the original source would be transformed, and we hope that it's not used
// in another context too where we don't want it to be transformed?
generateTests();

Something like:

If program body is test-module, within the given module context inspect top-level (or nested) function invocations and see if they contain/are tests. If they do, then transform?

I'm not sure how much of this is possible / easy to do / etc, just shooting from the hip

let subject = run(() => this.owner.lookup('service:store').createRecord('foo', { size: 'big' }));
['big', 'small'].forEach(function (size) {
test('has another thing', function (assert) {
let subject = this.owner.factoryFor('component:foo-bar').create({ size });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be let subject = run(() => this.owner.lookup('service:store').createRecord('foo', { size })); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I keep moving the code snippet to the wrong place... the lines with similar names make it hard to grok where I am.
I'll move it again

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

Successfully merging this pull request may close these issues.

3 participants