Document how expect().toHaveProperty works with a dot in the property name.
See original GitHub issueDo 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:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Oops! I see you changed the title, so I won’t close this as it should be added to the documentation. Thanks!
I can update documentation 👍