Comments (4)
probably related to changes here, needs investigation #2170
from karate.
That's an interesting one ...
My understanding is that:
- a MatchOperation with type 'contains only' is created to validate
kittens: '#(^^expected)'
- since kittens is a list, type is converted into 'contains only deep'
- 'contains only deep' is passed to the MatchOperation that validates each item in the list, since they are objects and the deep operator applies to nested lists or objects, per doc
- then it is passed to the MatchOperation that validates bla, since it is a list
- and match
[{ b: '1'}]
contains deep{ b: '1'}
passes.
There are probably a few steps I missed/misunderstood, so feel free to correct me. But hopefully, the general idea is the right one.
Basically, as soon as contains only
is converted into contains only deep
, there's no way back.
If line 278 is commented so as to keep contains only
, the test fails as OP expects.
I suspect that if line 580 is changed so that contains only deep
is reverted back to contains only
, it would fail too.
Obviously, neither change is possible as it would break backwards compatibility.
I can't think of any other way to fix the issue, but maybe someone else will have an idea...
from karate.
@f-delahaye yes this is a complicated one :|
from karate.
Actually ... there might be a solution.
Line 278 is key, IMO.
This method handles macros, which presumably are the same thing as shortcuts. So when ^^ (contains only
) is specified, it gets converted to contains only deep
. Is this by design? This does not sound like the expected behaviour.
@ptrthomas we could comment out line 278, so that nestedType
remains contains only
? The test then fails, as expected by the user. This would be a breaking change, but we could add a new shortcut for contains only deep
, if needed.
With the line commented out, and using the standard syntax as opposed to the shortcuts:
match cat contains only deep { name: 'Billie', kittens: [{ id: 42, name: 'Wild' }, { id: 23, name: 'Bob', bla: { b: '1'} }]}
passes, but we did specify contains only deep
so that sounds reasonable.
from karate.
Related Issues (20)
- Missing header in spite of "configure headers" HOT 5
- afterScenario hook not running when scenario fails HOT 1
- File upload is not working when using Web driver when running test on Sauce Lab or Remote Grid HOT 7
- Karate does not work with Java 22 (?) => OK with Java 21 HOT 6
- Bug: Calling scenario with array argument of different object leads to unwanted behaviour HOT 1
- The switch from the iframe to the sub-iframe is not working HOT 1
- Chrome is not working from jenkins and getting driver config / start failed: start failed, options: {type=chrome, showDriverLog=true, addOptions=["--remote-allow-origins=*"], target=null} HOT 1
- replace graal with karate-js engine HOT 27
- Variables are lost after callonce java.lang.Thread.sleep() HOT 1
- [Improvement] Rename "request" keyword ? HOT 1
- Multiarch image for karatelabs/karate-chrome HOT 1
- getting this exception org.graalvm.polyglot.PolyglotException: not found: src/test/resources/payload/user.json in Karate HOT 2
- In Karate 1.2.0.RC1, the karate property set in karate-config.js file is coming as null when fetched in a Java File HOT 1
- Karate - Setting header for the subsequent calls on the same scenario is not working after updating to 1.x.x HOT 1
- Driver input method cannot type '[' HOT 6
- The request "path" can not be overwrited in mock.feature
- CRC of file being uploaded HOT 1
- MockServer/MockHandler performance HOT 1
- Doubt regarding afterScenario and afterFeature HOT 1
- I am not able to switch to new window from parent window. Switch page is not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karate.