Skip to content

Add option to wrap model.createRecord in runloop#117

Open
jbryson3 wants to merge 5 commits intoember-codemods:masterfrom
jbryson3:feature/wrap-model-createrecord-in-runloop
Open

Add option to wrap model.createRecord in runloop#117
jbryson3 wants to merge 5 commits intoember-codemods:masterfrom
jbryson3:feature/wrap-model-createrecord-in-runloop

Conversation

@jbryson3
Copy link
Copy Markdown
Contributor

Summary

This PR adds the ability for users to opt into wrapping a model.createRecord in an Ember run loop. This is to avoid this error: "You have turned on testing mode, which disabled the run-loop's autorun." encountered in older versions of Ember.

Changes

  • Added a Codeshift options section to the documentation to explain how to use the new option, what it does, and why you might need to use it
  • Added the ability to pass in jscodeshift options for a test. This is done via an input test naming convention - the-test-name.option1=foo.option2=bar.input.js
  • Cleaned up the code a bit in the createModel section so its easier to read. This was accomplished by putting the nested 'j' calls in a named functions, and then calling those functions later.
p.replace(createRecordExpression(createRecordArg));

// instead of
p.replace(
  j.callExpression(
    j.memberExpression( //....
 ));

Dependencies

Depends on and branched off of #116

@Turbo87
Copy link
Copy Markdown
Collaborator

Turbo87 commented Feb 21, 2020

what do you think about having something like a setup-model-test2.options.json file instead of encoding the options in the filenames?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants