We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My test:
it('Retorna um Cliente', () => { const Clientes = { findOne: td.function(), populate: td.function() }; td.when(Clientes.findOne({ _id: '58b431fd11b5272360652e45' }).populate('endereco.cidade')).thenResolve(modeloPadrao); const clientesController = new ClientesController(Clientes); return clientesController .getById({ params: { _id: '58b431fd11b5272360652e45' } }) .then(response => expect(response.data).to.be.eql(modeloPadrao)); });
My controller:
getById(req) { return this.Clientes.findOne(req.params) .populate('endereco.cidade') .then(result => defaultResponse(result)) .catch(error => errorResponse(error.message)); }
Error: TypeError: Cannot read property 'populate' of undefined
The text was updated successfully, but these errors were encountered:
You're trying to chain findOne and populate, but the Clientes object you've defined doesn't allow that.
findOne
populate
Clientes
You should:
const Clientes = td.object(['findOne', 'populate']) td.when(Clientes.findOne({ _id: 'lol' })).thenReturn(Clientes) td.when(Clientes.populate('endereco.cidade')).thenResolve(modeloPadrao)
Sorry, something went wrong.
No branches or pull requests
My test:
My controller:
Error: TypeError: Cannot read property 'populate' of undefined
The text was updated successfully, but these errors were encountered: