Comments (2)
Seems that the following is producing the right result
const itemSuite = create("itemSuite", (item, path) => {
test(`${path}.name`, "Name is required", () => {
enforce(item.name).isNotEmpty();
});
});
const mainSuite = create("mainSuite", (data, field) => {
only(field);
test("a", "A != B", () => {
enforce(data.a).equals(data.b);
});
itemSuite(data.innerItem, "innerItem");
each(data.items, (item) => {
itemSuite(item, `items.${item.guid}`);
});
});
const result = mainSuite(
{
a: "a",
b: "b",
items: [
{ name: "", guid: 1 },
{ name: "", guid: 2 },
{ name: "test", guid: 3 },
],
innerItem: {
name: "",
},
},
["items.1.name", "innerItem.name"]
); // result.errorCount = 2
Would you advise devs to use this library this way?
from vest.
Hey @codrin-iftimie, sorry for responding late. I have been traveling.
Yes, your approach should work as expected, and most operations should work correctly when nesting suites this way.
only
, omitWhen
, and skipWhen
, include
should work with no problem. Querying and outputting these results should work as well.
By the way, this will work just the same if you simply use a function for your nested suite, and do not create an entire suite for that. Meaning, simply the callback of your sub suite is sufficient for this. It will be a little easier on performance.
In the future, I might add a few more features around the approach that you selected (creating two suites), but for now, these two approaches are identical in terms of functionality.
from vest.
Related Issues (20)
- Dynamic fields HOT 6
- Vest@5 is ready! Help test it!
- Last next release does not include development builds in dist HOT 4
- Debounce HOT 9
- Pending info in summary HOT 7
- Omit without when HOT 5
- `skip` and `only` on the same level HOT 5
- Subscribe HOT 6
- Migration guide example code - eager -> mode HOT 1
- Problem with OmitWhen executing code when condition is true HOT 2
- Done and empty suite HOT 3
- In SvelteKit, all the asynchronous tests below do not work at all. HOT 1
- Cannot find name 'Predicate'. Did you mean 'Predicates'? HOT 5
- only.group missing HOT 4
- Stateless suite HOT 2
- isDate alway fails HOT 7
- Multiple groups using same tests function HOT 2
- Eager mode does not work in a group/omitWhen/skipWhen HOT 5
- isNotEmpty on a numeric field HOT 2
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 vest.