Open fernandogmar opened 7 years ago
I see what you mean, and added separate parameters to the snap-shot-core api. See example in https://github.com/bahmutov/snap-shot-core-tape-demo
PS: also love that you use Ramda
Awesome! I am looking forward to seeing what you get :smile: let me know if I can help :wink:
PS: I got Ramda and Kefirjs as a good combo
I know! https://glebbahmutov.com/blog/ramda-for-reactive-streams/
BTW, the changes have been pushed, but I'm thinking what if you could pass assert.equal
function directly into snap-shot-core? then snap-shot-core
would fetch value from snapshot and if found just call your assert.equal
, making the test runner do its work. It would look like this
const {test} = require('tape')
const snapshot = require('snap-shot-core')
test('a test', (assert) => {
snapshot({
what: 43,
__filename,
specName: assert.name,
equal: assert.equal
})
assert.end()
})
Cool! and smart solution! that is only for snap-shot-core, right? Now I am guessing how this could be used directly with snap-shot, I think it is going to be bit more difficult to get it working for example with data-driven... :thinking:
snapshot(isPrime, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Using just snap-shot-core.... I am thinking out loud... for now I just can do something like...?
const {test} = require('tape')
const snapshot = require('snap-shot-core')
test('a test', (assert) => {
[1, 2, 3, 4, 5, 6, 7, 8, 9].map((value) => {
snapshot({
what: isPrime(value),
__filename,
specName: assert.name,
equal: assert.equal
})
})
assert.end()
})
BTW, I have been playing with https://github.com/bahmutov/snap-shot-core-tape-demo ;), and I saw your changes on your commit. Really fast work ;)
Another thing, What it is __filename
?
UPDATE: ok I got it https://nodejs.org/api/globals.html#globals_filename
Thanks for all!
Hi bahmutov,
I am using tape for my tests (good post: https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4)
I was looking for a library that allows you to work with snapshots no matter your testing framework is, and I was a bit excited after reading this: https://glebbahmutov.com/blog/snapshot-testing/
but it looks like it was not as agnostic as I wish. Just following the code to know if it could be easily hacked I relized that you are using this snap-shot-core.... and you are using the function raiseIfDifferent where actually you compare the values... and do whatever is needed... right?
maybe it could be an option for having this function raiseIfDifferent as a parameter for snapshot... so custom actions can be made... more or less like you did with compare ;)
I would add an example of what I mean here, just to get an idea.
First an example of a test file using tape
following what you did on cypress-system.js
The previous test could be written as:
I hope you get the point, no idea if this is possible or even there are better alternatives, but it would awesome this library would be really agnostic to the testing framework :smile:
What do you think?