Ember-power-select: Version > 2.0.0 / Must setup rendering context

Created on 8 Apr 2018  路  13Comments  路  Source: cibernox/ember-power-select

Version > 2.0.0

import { selectChoose } from 'ember-power-select/test-support';
// ...
await selectSearch('[data-test-custom-field="Host"]', 'Carlos Doe');
// ...

image 2018-04-08 at 12 04 43 am

Most helpful comment

Any progress here? Due to this problem we are forced to still use ember-power-select version 1.10.4 as the latest working version. When updating to any version >= 2.0.0 our tests are failing with "Must setup rendering context before attempting to interact with elements." All other npm packages used are at their latest version. (i.e. [email protected])

All 13 comments

For context, what version of ember-cli-qunit are you using?

@cibernox We're on "ember-cli-qunit": "^4.3.2". 馃檹

Hitting the same error using clickTrigger from ember-basic-dropdown. We're using ember-cli-mocha rather than ember-cli-qunit

Error: Must setup rendering context before attempting to interact with elements.
    at getRootElement (assets/test-support-3b6f7d369d74366c350475c8ccf8f11f.js:52931:13)
    at getElement (assets/test-support-3b6f7d369d74366c350475c8ccf8f11f.js:52315:53)
    at then (assets/test-support-3b6f7d369d74366c350475c8ccf8f11f.js:52544:45)
    at tryCatcher (assets/vendor-cbe91fb5da5a795c2b5bc5d74a6cc3fc.js:75156:21)
    at invokeCallback (assets/vendor-cbe91fb5da5a795c2b5bc5d74a6cc3fc.js:75328:33)
    at publish (assets/vendor-cbe91fb5da5a795c2b5bc5d74a6cc3fc.js:75314:9)
    at Ember.run.backburner.schedule (assets/test-support-3b6f7d369d74366c350475c8ccf8f11f.js:56788:9)
    at invoke (assets/vendor-cbe91fb5da5a795c2b5bc5d74a6cc3fc.js:33666:24)
    at Queue.flush (assets/vendor-cbe91fb5da5a795c2b5bc5d74a6cc3fc.js:33586:25)
    at DeferredActionQueues.flush (assets/vendor-cbe91fb5da5a795c2b5bc5d74a6cc3fc.js:33739:31)

Any progress here? Due to this problem we are forced to still use ember-power-select version 1.10.4 as the latest working version. When updating to any version >= 2.0.0 our tests are failing with "Must setup rendering context before attempting to interact with elements." All other npm packages used are at their latest version. (i.e. [email protected])

Same problem here with ember 2.18.2 and quint 4.3.2.

I might have a hint. Something something lazy loading. When running my broken test locally in Chrome, if I put a debugger; just before await selectSearch('.ember-power-select-trigger', 'blah') I can inspect the DOM. I notice that the '.ember-power-select-trigger' div has spans inside of it instead of inputs. Looking at the selectSearch function, it does have some selectors for input[type=search] which might not be present yet. https://github.com/cibernox/ember-power-select/blob/c2f3bc183c00173be7d8bec53cfda18d6a0f11ff/addon-test-support/index.js#L59

This person got the same error, and the link has some info about lazy loading, but the suggested helper sends me down a maze of errors. https://github.com/emberjs/ember-test-helpers/issues/281

It turns out in our case, we were using the old style of acceptance tests, without using moduleForAcceptance. Instead, we had a manual start-app.js file that wasn't setting up the test context. If you're in the same boat:

Add the following to start-app.js:

import { setContext } from 'ember-test-helpers';
...
// inside the function:
QUnit.config.current.testEnvironment.owner = application.__deprecatedInstance__;
setContext(QUnit.config.current.testEnvironment);

and then to destroy-app.js:

import { unsetContext } from 'ember-test-helpers';
...
// inside the function:
unsetContext();

(thanks @rwjblue for that solution!)

We also had the same issue with some component integration tests. The only solution I could come up with there was to upgrade to the new testing API for those files. It actually wasn't too painful, thanks to https://github.com/rwjblue/ember-qunit-codemod and https://github.com/simonihmig/ember-test-helpers-codemod

@danwenzel Thank you for sharing this! I'll try it! 馃檹

We have already the new style of acceptance tests but still the problem with selectSearch.

Additionally adding the changes from @danwenzel did not really help.

I can confirm that in my project switching to the new style acceptance tests (using setupApplicationTest) resolves the "must setup rendering context"-issue.

setupApplicationTest was the keyword to fix our acceptance tests. Now everything is working.
Thank you to @nfc036

EDIT: Was not fixed. using setupApplicationTest doesn't work with Ember 2.18 and the tests are just skipped if adding this new style of tests.

I was able to get the new style of tests working configuring it like described in https://github.com/emberjs/ember-qunit/issues/309
Nevertheless there are still problems because andThen is not workung and other errors are occuring.

Was this page helpful?
0 / 5 - 0 ratings