Skip to content

[Question] Are Spies and/or Mocks supported by JS Test Framework? #954

@Vinai

Description

@Vinai

Is there a built in way to spy on existing objects using the test framework?
I've looked at the qunit cookbook and the api docs but that turned up nothing, I might have missed it though.

What I'm looking for is something like PHPUnit mocks, or Jasmine Spies.

var foo = jQuery('#foo');
spyOn(foo, 'setWidth');
// execute function under test
expect(foo.setWidth).toHaveBeenCalledWith(100);

Setting the expectations beforehand like in PHPUnit or mockery would work just as well.
Of course its possible to create that functionality manually, but it would be cool if it would be part of the testing framework since its such a common requirement.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions