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.

Document how expect().toHaveProperty works with a dot in the property name.

See original GitHub issue

Do you want to request a feature or report a bug? bug

What is the current behavior? toHaveProperty fails with nested property that has a dot (“.”) in the name.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test. Here is the data. It was originally xml from a soap message, then converted to json via package xml2js. let response = {"AccessPolicyConfig": "false", "DefaultAccessPolicy": "true", "Dot1X": "false", "HttpDigest": "false", "KerberosToken": "false", "OnboardKeyGeneration": "false", "RELToken": "false", "RemoteUserHandling": "false", "SAMLToken": "false", "SupportedEAPMethods": "0", "TLS1.0": "false", "TLS1.1": "false", "TLS1.2": "false", "UsernameToken": "true", "X.509Token": "false"}

These tests fail: expect(response).toHaveProperty(‘TLS1.0’) expect(response).toHaveProperty(‘TLS1.1’) expect(response).toHaveProperty(‘TLS1.2’) expect(response).toHaveProperty(‘X.509Token’)

REPL.IT example: https://repl.it/@hawkeye64/dot-in-property-test-fail

What is the expected behavior? The have expect().toHaveProperty() to not fail.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system. Jest v22.1.2 node v7.4.0 linux/amd64

config.json: { “testRegex”: “.*-test\.js$”, “testEnvironment”: “node” }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
hawkeye64commented, Feb 24, 2018

Oops! I see you changed the title, so I won’t close this as it should be added to the documentation. Thanks!

2reactions
czystylcommented, Feb 26, 2018

I can update documentation 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

dot character in property name - javascript - Stack Overflow
This shows you how you might use this function with such a property. // Referencing keys with dot in the key itself expect(houseForSale)....
Read more >
Jest Expect - w3resource
toHaveProperty to check if property at provided reference keyPath exists for an object. If you are checking deeply nested properties in an ...
Read more >
Expect · Jest
This matcher uses 'deep equality' (like toEqual() ) and recursively checks the equality of all fields. The following example contains a houseForSale object...
Read more >
Expect - Jest
Use .toHaveProperty to check if property at provided reference keyPath exists for an object. For checking deeply nested properties in an object ...
Read more >
Expect / Should - Chai Assertion Library
expect (function () {}).to.not.throw(); expect({a: ... If . or [] are part of an actual property name, they can be escaped by adding...
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