Comments (5)
Thanks for taking care of this :)
from ospec.
@glantucan Not sure how we'll fix this, but in the mean time, you can write your own validator using the .satisfies()
assertion.
Schematically:
const compareImmutable = (reference) => (candidate) => {
const discrepancies = []
// actually compare `reference` and `candidate`, populate `discrepancies` if needed
return {pass: discrepancies.length === 0, message: discrepancies.join("\n")}
}
o("test", () => {
o(candidate).satisfies(compareImmutable(reference))
})
You'll probably want a recursive helper of the form
_compareImmutable(reference, candidate, discrepancies) {}
from ospec.
So, this is not something we can fix in core, as these objects are not deepEquals according to our definition, and out API leaves no room for adding an exception list.
Here's a rudimentary port of deepEquals to support seamless-immutable
arrays (a slightly modified version of ospec's deepEquals). Feel free to embellish it to your fit needs.
Edit: better demo
from ospec.
Rethinking about this, I may have gotten this wrong... Non-enumerable properties are not compared on objects, we should skip them on arrays too for consistency.
from ospec.
This is fixed in v4.1.6
from ospec.
Related Issues (20)
- Remove devDependencies before publish to NPM HOT 1
- ospec: use string substitution to expose values in assertion reports HOT 4
- How to use ospec for components having imports HOT 4
- 'throws' doesn't work with async functions HOT 4
- ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows 10 HOT 4
- deepEquals can't handle objects with a null prototype
- The report should show the own properties of errors that were caught in tests
- Assertion descriptions don't interpolate when used with tagged template literal syntax
- `.satisfies()` is too verbose, `.notSatisfies()` and `.notDeepEquals()` are of little use
- Complex assetions like `deepEquals` and `satisfies` plugins should differentiate between bail outs and internal errors
- Logging: bailout should be reported apart from standard failures
- Lost assertions in async tests HOT 1
- Immutable woes? HOT 1
- Adapt the `lock()` mechanism as a core part of o.spy()
- re-think the results output
- Context and running streaks in parallel.
- Failed assertion reporting does unnecessary string substitution HOT 2
- spy.calls doesn't seem to match TypeScript definitions
- `o.before()` within a `o.spec` still runs even when no tests are running HOT 4
- Question: View realtime test progress?
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 ospec.