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

Object.assign does not merge Symbols correctly #2189

Closed
mike247 opened this issue Nov 19, 2019 · 4 comments
Closed

Object.assign does not merge Symbols correctly #2189

mike247 opened this issue Nov 19, 2019 · 4 comments
Assignees
Labels
Milestone

Comments

@mike247
Copy link

mike247 commented Nov 19, 2019

What is your Test Scenario?

After starting the test runner with chrome, and putting a t.debug() at the very start before doing anything, going into the console and running the following does not work as expected

Screen Shot 2019-11-19 at 11 45 09 PM

What is the Current behavior?

The Object.assign is failing to merge the symbol key into the object

What is the Expected behavior?

The Symbol should be merged into the object
Screen Shot 2019-11-19 at 11 49 46 PM

What is your web application and your TestCafe test code?

This is application independant

Your complete test code (or attach your test files):

No tests are being run

Steps to reproduce

  1. Have a simple test
  2. Place a t.debug() as the first thing to do after opening a url
  3. Unlock the page
  4. Right click and open the dev tools
  5. Go to the console
  6. Repeat the code in the screenshots

Your Environment details:

  • testcafe version: 1.6.0
  • node.js version: 11.12.0
  • command-line arguments: testcafe --skip-js-errors chrome ./tests
  • browser name and version: chrome, 78.0.3904.97
  • platform and version: Mac OS X 10.13.6
@Farfurix Farfurix self-assigned this Nov 21, 2019
@Farfurix
Copy link
Contributor

@mike247

Hello,

Thank you for this information. I've reproduced the issue.
Could you please describe your specific scenario: why you need to use Object.assign(..., { [Symbol(...)] }) to debug your test?

For the team:
In this code we are trying to get keys from the following object: { [Symbol('test')]: "test" }.

const sourceKeys = nativeMethods.objectKeys.call(window.Object, source);

Getting object symbols:

> Object.getOwnPropertySymbols.call(window.Object, { [Symbol('test')]: "test" })
< [Symbol(test)]
    0: Symbol(test)
    length: 1
    __proto__: Array(0)

@Farfurix Farfurix transferred this issue from DevExpress/testcafe Nov 21, 2019
@mike247
Copy link
Author

mike247 commented Nov 21, 2019

Hey

We use the merging of Symbols to track our form inputs, and to validate objects that can be modified by several forms over seperate pages

Here is an example

 Object.assign(person, {
      [Symbol('touched')]: {
        firstName: !!person.firstName,
        lastName: !!person.lastName,
        day: !!person.day || !!person.age,
        month: !!person.month || !!person.age,
        year: !!person.year || !!person.age
      },
      [Symbol('valid')]: {
        firstName: !!person.firstName,
        lastName: !!person.lastName,
        day: !!person.day || !!person.age,
        month: !!person.month || !!person.age,
        year: !!person.year || !!person.age
      }
    })

We are extending our Person object with the 'Valid' and 'touched' symbols, these are used to track if the form field representing those Keys was touched or is valid

One of the key benefits of this approach is we are able to track form validation inside the objects that are modified directly while still being able to call Object.keys(person) to filter out all this metadata.

Because the Object.assign is not merging in symbols, while running automated tests all our forms are always invalid and the automated software cannot continue onto the next step

I hope this answers your question!

@Farfurix
Copy link
Contributor

@mike247

Thank you for the clarification. I will add this issue to the current development sprint. Stay tuned for our updates in this thread.

@lock
Copy link

lock bot commented Dec 8, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked Issues that were automatically locked by the Lock bot label Dec 8, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants