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

Provide Mcoks #11

Open
jonny-improbable opened this issue Mar 4, 2019 · 0 comments
Open

Provide Mcoks #11

jonny-improbable opened this issue Mar 4, 2019 · 0 comments

Comments

@jonny-improbable
Copy link

jonny-improbable commented Mar 4, 2019

Thanks for this awesome project 👍

As part ofmaintaining a suite of Google App Scripts, we have created a number of mock objects which are loaded into the node environment and allow our tests, and subjects under test, to make use of the Goolge App Script globals - I wondered if gas-local would be a good repository to house them for others to use?

These mocks are simple and provide a mixture of fakes and test-doubles, for example:

global.Utilities = {};

Utilities.formatDate = jest.fn(function () {
  return "";
});

Utilities.base64Encode = jest.fn(function (str) {
  return btoa(str);
});

One potential problem I can forsee is being strongly opinionated on using Jest for creating mocks; whilst we could remove all calls to jest.fn(); this would put a lot of onus on the test-author to mock out globals in their test, ie:

describe("my suite", () => {
  it("should do something...", () => {
    // Setup jest mocks
   Utilities.formatDate = jest.fn();
  });
});

Do let me know if I've missed something; I feel like I'm reinventing the wheel to large extent with implementing all those mocks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant