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

Running tests shows Warnings and Deprecation's #4416

Closed
frunjik opened this issue Jun 1, 2016 · 9 comments
Closed

Running tests shows Warnings and Deprecation's #4416

frunjik opened this issue Jun 1, 2016 · 9 comments
Labels
🏷️ cleanup This PR primarily removes deprecated functionality

Comments

@frunjik
Copy link
Contributor

frunjik commented Jun 1, 2016

When i run the tests i get warnings and deprecation's.

Before i try to see if i can get rid of them i want to understand if this is expected behavior, or am i doing something wrong ?

@bmac
Copy link
Member

bmac commented Jun 2, 2016

Hi @frunjik. These warnings are expected. Most of them are from recent deprecations and warnings added to the code base. Since they don't fail the build these cleaning up the old tests often get missed. If you have some time to get rid of some of these that would be great.

@frunjik
Copy link
Contributor Author

frunjik commented Jun 2, 2016

My knowledge lacks to be able to solve the issues myself.
I have identified the offending tests (by trial and error).
I include a list of offending tests per message.
Maybe you can help me by hinting at what the right approach would be to get rid of the messages ?

DEPRECATION: Using the global version of DS is deprecated. Please either import the specific modules needed or import DS from 'ember-data';. [deprecation id: ember-data.global-ds]

  • Solvable by explicitly importing Ember.DS in tests/ember-data-initializers.js

WARNING: FEATURE["ds-serialize-ids-and-types"] is set as enabled, but FEATURE flags are only available in canary builds.

  • This is not tied to a particular test (it shows always even when running 0 tests)

DEPRECATION: The adapter returned an array for the primary data of a queryRecord response. This is deprecated as queryRecord should return a single record. [deprecation id: ds.serializer.rest.queryRecord-array-response]
tests/integration/adapter/rest-adapter-test.js

  • test("queryRecord - returning an array picks the first one but saves all records to the store", ...

DEPRECATION: RESTSerializer.normalizeHash has been deprecated. Please use serializer.normalize to modify the payload of single resources. [deprecation id: ds.serializer.normalize-hash-deprecated]
tests/integration/serializer/rest.js

  • test('normalizeHash normalizes specific parts of the payload', ...
  • test('normalizeHash works with transforms', ...

WARNING: There is no attribute or relationship with the name notInMapping on post. Check your serializers attrs hash.
tests/json-serializer-test.js

  • test('normalizeResponse ignores unmapped attributes', ...

WARNING: Ember Data expected to find records with the following ids in the adapter response but they were missing: [igor]
tests/unit/store/adapter-interop-test.js

  • test("store.fetchRecord reject records that were not found, even when those requests were coalesced with records that were found", ...

WARNING: Interacting with a record errors object will no longer change the record state.
tests/integration/records/error.js

  • test('adding errors during root.loaded.created.invalid works', ...
  • test('adding errors root.loaded.created.invalid works', ...
  • test('adding errors root.loaded.created.invalid works add + remove + add', ...
  • test('adding errors root.loaded.created.invalid works add + (remove, add)', ...

tests/unit/model/errors.js (all tests in this module give the warning)

  • test("add error", ...
  • test("get error", ...
  • test("remove error", ...
  • test("remove same errors from different attributes", ...
  • test("clear errors", ...

@frunjik
Copy link
Contributor Author

frunjik commented Jun 22, 2016

Tracking progress

  • DEPRECATION: Using the global version of DS is deprecated. Please either import the specific modules needed or import DS from 'ember-data';. [deprecation id: ember-data.global-ds]
    solved by remove DEPRECATION: Using the global version of DS is deprecated when running tests #4418
  • WARNING: FEATURE["ds-serialize-ids-and-types"] is set as enabled, but FEATURE flags are only available in canary builds. [no specific files/tests / is global]
  • DEPRECATION: The adapter returned an array for the primary data of a queryRecord response. This is deprecated as queryRecord should return a single record. [deprecation id: ds.serializer.rest.queryRecord-array-response] [1 file / 1 test]
  • DEPRECATION: RESTSerializer.normalizeHash has been deprecated. Please use serializer.normalize to modify the payload of single resources. [deprecation id: ds.serializer.normalize-hash-deprecated] [1 file / 2 tests]
  • WARNING: There is no attribute or relationship with the name notInMapping on post. Check your serializers attrs hash.[1 file / 1 test]
  • WARNING: Ember Data expected to find records with the following ids in the adapter response but they were missing: [igor] [1 file / 1 test]
  • WARNING: Interacting with a record errors object will no longer change the record state. [2 files / 9 tests]

@eshtadc
Copy link
Contributor

eshtadc commented Jun 27, 2016

With regards to the queryRecord warning, there are two tests (next to each other) in rest-adapter-test. One "queryRecord - returning an array picks the first one but saves all records to the store" seems to run counter to "queryRecord - returning an array is deprecated". I'm not sure which of these tests is the valid one. It appears that the code is following the latter (deprecation warning).

bmac added a commit that referenced this issue Jun 27, 2016
[CLEANUP beta] Remove feature flag for ds-serialize-ids-and-types (shipped in 2.6) #4416
@bmac
Copy link
Member

bmac commented Jun 27, 2016

There are some tests in the Ember Data repo that test for deprecated behavior. I don't believe we want to remove those tests yet because the deprecated behavior is still valid until Ember Data 3.0 and we don't want to accidentally break it before then.

Recently I discovered that the ember-dev library injects an ignoreDeprecation method into the test environment. We can use that to silence known deprecations for valid tests like "queryRecord - returning an array picks the first one but saves all records to the store" by wrapping the call that triggers deprecated code in

ignoreDeprecation(function() {
  //... some code that is deprecated
})

We may also need to add ignoreDeprecation to the list of acceptable globals in our tests.

@eshtadc
Copy link
Contributor

eshtadc commented Jun 27, 2016

That sounds great - unfortunately it seems to only apply to synchronous code. I opened a corresponding issue emberjs/ember-dev#165
Will try to continue on this (or work on that as well).

@bmac
Copy link
Member

bmac commented Jun 27, 2016

One technique that is used in some places in the Ember Data tests is to mock out the API response and wrap some async code in an Ember.run(function() { ... }) which will make the code run as if it was synchronous from outside the Ember.run call. While, this may not be possible everywhere I suspect some of the deprecations could be silenced by wrapping the Ember.run in ignoreDeprecation.

@frunjik
Copy link
Contributor Author

frunjik commented Jun 27, 2016

Thx for helping me understand :)

A general test question:

To test locally i run:

ember serve -lrp 49155 - localhost:4200/tests
and
ember test production=environment

both succeed...

But when i push the commit, the build (sometimes) fails ...

What command(s) do i need to invoke to simulate the test run's the CI's do ?

@wecc wecc added the Cleanup label Oct 29, 2016
@wecc
Copy link
Contributor

wecc commented Oct 29, 2016

@frunjik Thank you so much for tackling this and please forgive the late response. Are you still willing to work on this? Is there anything I can do to help? Feel free to reach out in the Ember Community Slack.

@runspired runspired added 🏷️ cleanup This PR primarily removes deprecated functionality and removed Cleanup labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ cleanup This PR primarily removes deprecated functionality
Projects
None yet
Development

No branches or pull requests

5 participants