GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement spy library for cleaner spec files · Issue #871 · googleapis/google-cloud-node

Implement spy library for cleaner spec files #871

New issue
Copy link
New issue
Copy link
Closed
Closed
Implement spy library for cleaner spec files#871
Copy link
Assignees
callmehiphop

Description

@callmehiphop
callmehiphop
opened on Sep 17, 2015
Issue body actions

There's a bit of clutter in our test files when stubbing out methods in our unit tests - https://github.com/GoogleCloudPlatform/gcloud-node/blob/469c3ac4a81dcd43dfd1d1b8bbc84cea6afe49dd/test/bigquery/table.js#L38.

I propose we implement a spy library to clean up some of this.

Activity

  1. callmehiphop
    added
    enhancement
    testing
    on Sep 17, 2015
  2. stephenplusplus commented on Sep 17, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 17, 2015
    Contributor
    More actions

    👍 Have any favorites?

  3. callmehiphop commented on Sep 18, 2015

    @callmehiphop
    callmehiphop
    on Sep 18, 2015
    ContributorAuthor
    More actions

    I've really only used jasmine and sinon for spies, jasmine obviously doesn't fit.. so sinon? Not particular partial to it though.

  4. stephenplusplus
    assigned
    stephenplusplus
    and
    callmehiphop
    and unassigned
    stephenplusplus
    on Sep 18, 2015
  5. stephenplusplus commented on Sep 18, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 18, 2015
    Contributor
    More actions

    Sorry to assign/re-assign! I think it might be best if you take first crack at this. Maybe just do a test file so I can see the patterns you use, then I can do the grunt work of applying it suite-wide.

  6. callmehiphop commented on Sep 18, 2015

    @callmehiphop
    callmehiphop
    on Sep 18, 2015
    ContributorAuthor
    More actions

    No worries! This is what I was kind of thinking

    var sinon = require('sinon').sandbox.create();
    
    describe('SomeObject', function() {
    
      afterEach(function() {
        sinon.restore();
      });
    
      describe('method', function() {
        it('should do something', function() {
          var data = {};
    
          sinon.stub(util, 'someOtherMethod', function() {
            return data;
          });
    
          assert.strictEqual(SomeObject.method(), data);
        });
      });
    });

    If this isn't enough to go on, I'll try and get a real example going soon!

  7. stephenplusplus commented on Sep 22, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 22, 2015
    Contributor
    More actions

    I tried re-writing a few things with sinon, but ended up with code that looked very similar, except using an abstraction rather than "just plain JavaScript" of overwriting a method. That doesn't mean this is a bad idea at all, but probably just that I'm not seeing what you see see.

    Could you show how you would re-write the example from your first post? (https://github.com/GoogleCloudPlatform/gcloud-node/blob/469c3ac4a81dcd43dfd1d1b8bbc84cea6afe49dd/test/bigquery/table.js#L38)

  8. stephenplusplus commented on Aug 26, 2016

    @stephenplusplus
    stephenplusplus
    on Aug 26, 2016
    Contributor
    More actions

    Going to close since @callmehiphop has started integrating sinon where it was helpful for Bigtable. I don't think the cost of a full re-write of our tests is worth it, but we can continue injecting it where we see its value. If you feel differently, just re-open!

  9. stephenplusplus
    closed this as completedon Aug 26, 2016
  10. sofisl
    added a commit that references this issue on Nov 11, 2022

    docs: clarified some LRO types (#871)

    00ac4f2
  11. sofisl
    added 9 commits that reference this issue on Jan 27, 2026

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    3eacb6b

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    1d136aa

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    9ea89a9

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    fd1c07c

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    7ced378

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    e9bf919

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    441be55

    docs: update docs-devsite.sh to use latest node-js-rad version (#871)

    c7d095b

    chore(deps): update dependency @types/big.js to v6 (#871)

    0952327
  12. sofisl
    added a commit that references this issue on Feb 26, 2026

    fix(deps): update dependency @google-cloud/paginator to v3 (#871)

    a596963
  13. GautamSharda
    added a commit that references this issue on Mar 11, 2026

    chore: release 1.4.1 (#871)

    d965ef1
  14. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    docs: readme.md to include creation of service account client (google…

    7a90777
  15. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    chore: release 3.4.0 (#871)

    f5a2de9

    chore: release 3.4.0 (#871)

    4c5f065
  16. feywind
    added a commit that references this issue on Mar 27, 2026

    chore: release 1.4.1 (#871)

    757b5ba
  17. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    chore: release 3.4.0 (#871)

    a2107ff
  18. thiyaguk09
    added a commit that references this issue on May 5, 2026

    chore: release 3.4.0 (googleapis#871)

    53cc030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @callmehiphop
    callmehiphop

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.