{"id":13646017,"url":"https://github.com/google/gjstest","last_synced_at":"2025-04-21T17:31:54.286Z","repository":{"id":20051699,"uuid":"23320130","full_name":"google/gjstest","owner":"google","description":"A fast javascript unit testing framework that runs on the V8 engine.","archived":true,"fork":false,"pushed_at":"2019-05-02T21:42:03.000Z","size":2830,"stargazers_count":129,"open_issues_count":6,"forks_count":48,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-19T22:27:21.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-25T16:11:41.000Z","updated_at":"2025-01-08T04:29:59.000Z","dependencies_parsed_at":"2022-08-31T06:21:57.487Z","dependency_job_id":null,"html_url":"https://github.com/google/gjstest","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgjstest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgjstest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgjstest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgjstest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/gjstest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250100554,"owners_count":21374966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:02:46.865Z","updated_at":"2025-04-21T17:31:51.632Z","avatar_url":"https://github.com/google.png","language":"C++","readme":"Google JS Test is a fast javascript unit testing framework that runs on the [V8\nengine], without needing to launch a full browser. Features include:\n\n  * Extremely fast test startup and execution time, without having to run a\n    browser.\n  * Clean, readable output in the case of both passing and failing tests.\n  * A [browser-based test runner][browser-runner] that can simply be refreshed\n    whenever JS is changed.\n  * Style and semantics that resemble [Google Test][gtest] for C++.\n  * A built-in mocking framework that requires minimal boilerplate code (e.g. no\n    `$tearDown` or `$verifyAll`) with style and semantics based on the [Google\n    C++ Mocking Framework][gmock].\n\n[V8 engine]: http://code.google.com/p/v8/\n[browser-runner]: https://github.com/google/gjstest/wiki/Frequently-asked-questions\n[gtest]: http://code.google.com/p/googletest/\n[gmock]: http://code.google.com/p/googlemock/\n\nThe trade-off is that since tests are run in V8 without a browser, there is no\nDOM available. You can still use Google JS Test for tests of DOM-manipulating\ncode however; see [\"Is it for me?\"][for-me] for more details.\n\n[for-me]: https://github.com/google/gjstest/wiki/Is-it-for-me%3F\n\n# Example #\n\nBelow is an example of a basic test for a class called `UserInfo`, which accepts\na database lookup function in its constructor.\n\n```JavaScript\nfunction UserInfoTest() {\n  // Each test function gets its own instance of UserInfoTest, so tests can\n  // use instance variables to store state that doesn't affect other tests.\n  // There's no need to write a tearDown method, unless you modify global\n  // state.\n  //\n  // Create an instance of the class under test here, giving it a mock\n  // function that we also keep a reference to below.\n  this.getInfoFromDb_ = createMockFunction();\n  this.userInfo_ = new UserInfo(this.getInfoFromDb_);\n}\nregisterTestSuite(UserInfoTest);\n\naddTest(UserInfoTest, function formatsUSPhoneNumber() {\n  // Expect a call to the database function with the argument 0xdeadbeef. When\n  // the call is received, return the supplied string.\n  expectCall(this.getInfoFromDb_)(0xdeadbeef)\n    .willOnce(returnWith('phone_number: \"650 253 0000\"'));\n\n  // Make sure that our class returns correctly formatted output.\n  expectEq('(650) 253-0000', this.userInfo_.getPhoneForId(0xdeadbeef));\n});\n\naddTest(UserInfoTest, function returnsLastNameFirst() {\n  expectCall(this.getInfoFromDb_)(0xdeadbeef)\n    .willOnce(returnWith('given_name: \"John\" family_name: \"Doe\"'));\n\n  // Make sure that our class puts the last name first.\n  expectEq('Doe, John', this.userInfo_.getNameForId(0xdeadbeef));\n});\n```\n\nThe test's output is clean and readable:\n\n    [ RUN      ] UserInfoTest.formatsUSPhoneNumber\n    [       OK ] UserInfoTest.formatsUSPhoneNumber\n    [ RUN      ] UserInfoTest.returnsLastNameFirst\n    user_info_test.js:32\n    Expected: 'Doe, John'\n    Actual:   'John Doe'\n    \n    [  FAILED  ] UserInfoTest.returnsLastNameFirst\n    [ RUN      ] UserInfoTest.understandsChineseNames\n    [       OK ] UserInfoTest.understandsChineseNames\n\n# Getting Started #\n\nSee [Installing][] for information about installing Google JS Test on your\nsystem. Once you've done so, [Getting started][started] will take you through an\nend to end example of using Google JS Test. While writing your own tests, you\ncan use the [Matchers][] and [Mocking][] pages for reference.\n\n[Installing]: https://github.com/google/gjstest/wiki/Installing\n[started]: https://github.com/google/gjstest/wiki/Getting-started\n[Matchers]: https://github.com/google/gjstest/wiki/Matchers\n[Mocking]: https://github.com/google/gjstest/wiki/Mocking\n","funding_links":[],"categories":["C++","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fgjstest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fgjstest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fgjstest/lists"}