Skip to content
New issue

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

Making Mocking Easier #114

Open
acbart opened this issue Mar 10, 2024 · 0 comments
Open

Making Mocking Easier #114

acbart opened this issue Mar 10, 2024 · 0 comments
Labels
Sandbox Tool Issues pertaining to the Sandbox module (running student code)

Comments

@acbart
Copy link
Collaborator

acbart commented Mar 10, 2024

Playing around with Jest, I was delighted with how easy it was to mock out a class and spy on it.

const logSpy = jest.spyOn(global.console, 'log');
someComplexFunction();
expect(logSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledTimes(2);
expect(logSpy).toHaveBeenCalledWith('some important message');
expect(logSpy.mock.calls).toContainEqual(['some other message']);
logSpy.mockRestore();

I think we should adopt some similar syntax for Pedal, to quickly build up mock functions, classes, methods, and modules. Currently, you have to define new types (types/library/), the Sandbox mocked module, and extensions.

Make this better.

@acbart acbart added the Sandbox Tool Issues pertaining to the Sandbox module (running student code) label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sandbox Tool Issues pertaining to the Sandbox module (running student code)
Projects
None yet
Development

No branches or pull requests

1 participant