question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible with Embroider 's `staticAddonTestSupportTrees` optimized mode

See original GitHub issue

I’ve been testing out various addons we use in our app against Embroider and I’ve found an incompatibility between it and ember-cli-page-object.

Reproduction

Just setting up a simple page object and trying to use it in a test causes for the following test error:

Looks like you attempt to access page object property outside of test context. If that’s not the case, please make sure you use the latest version of “@ember/test-helpers

image

// tests/pages/users.js
import {
  create,
  visitable
} from 'ember-cli-page-object';

export default create({
  visit: visitable('/')
});
// tests/acceptance/index-test.js
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import page from 'embroider-spike/tests/pages/users';

module('Acceptance | index', function (hooks) {
  setupApplicationTest(hooks);

  test('visiting /index', async function (assert) {
    await page.visit();

    assert.equal(currentURL(), '/');
  });
});

I have a branch here which recreates the issue.

  • Run yarn test:ember -s -f=visiting. This uses Embroider and the test fails ❌
  • Run CLASSIC=true yarn test:ember -s -f=visiting. This uses the existing build pipeline and test passes ✅

Problem

The problem looks to stem from when you enable Embroider’s staticAddonTestSupportTrees setting.

From Embroider’s README

Enable staticAddonTestSupportTrees and staticAddonTrees and test your application. This is usually safe, because most code in these trees gets consumed via import statements that we can analyze. But you might find exceptional cases where some code is doing a more dynamic thing.

If I set this setting to false the tests pass fine.

The error mentions to make sure to have the latest version of @ember/test-helpers but doing a check it appears I am:

> yarn list ember-qunit
└─ ember-qunit@5.1.2
> yarn list @ember/test-helpers
└─ @ember/test-helpers@2.1.4

Some other info

I tried setting the context by calling page.setContext(this) in the test. This progresses the test but it then fails for another reason.

Ember.emberDeprecate is not a function

image

I don’t think this is related to ember-cli-page-object though. I think there’s an issue with the aliasing of the function to emberDeprecate. I’ve been able to replicate this exact thing in app code outside the context of ember-cli-page-object. I’m going to log an issue for that elsewhere.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ro0grcommented, Apr 4, 2021

Keep pushing it slowly. I think I’d like to make it work on the v2 branch first, cause there should be just a bit less magic, and if there are some blockers, we’re a bit safer to adjust it there.

Currently, it’s blocked with some issues related tobuildEmberPlugins(, which we’ve started to use in the #531. Reported it to the ember-cli-babel for now(https://github.com/babel/ember-cli-babel/issues/398).

3reactions
ro0grcommented, Feb 13, 2021

A quick update. I’ve started looking into this. The first blocker appeared is TS tests. Created a ticket for this(https://github.com/embroider-build/embroider/issues/691), Hopefuly, it’d be easy to fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`buildEmberPlugins` breaks embroider · Issue #398 - GitHub
In addon, with embroider enabled, and using the recent ... Incompatible with Embroider 's staticAddonTestSupportTrees optimized mode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found