I’m trying to figure out how to test methods/collections/publications with Jest. Here’s my repo and commit: https://github.com/Falieson/react-typescript-meteor/commit/42d07b60fc00574adbdf51ea9d50b01d3458ef18
I thought I could follow the example from https://github.com/orangecms/jest-meteor-demo using jest-meteor-stubs
like this
import { ValidatedMethod } from 'meteor/mdg:validated-method';
import Counters from './collections'
const {methods} = Counters
// describe('demo', () => {
// it('should add foo', () => {
// expect(ValidatedMethod).toHaveBeenCalledWith({
// name: 'Foo.add',
// run: jasmine.any(Function),
// validate: undefined,
// });
// });
// });
test('Methods \'counters.add\' works', ()=> {
expect(ValidatedMethod).toHaveBeenCalledWith({
name: 'Counters.methods.add',
run: jasmine.any(Function),
validate: undefined,
})
})
But I’m getting an error:
● Methods 'counters.add' works
expect(jest.fn()).toHaveBeenCalledWith(expected)
Expected mock function to have been called with:
[{"name": "Counters.methods.add", "run": Any<Function>, "validate": undefined}]
But it was not called.
And then I still haven’t figured out how to do publication and subscription testing w/ Jest.
I’d love an example set if someone knows of one.