{"id":22196986,"url":"https://github.com/valtech-commerce/jest-gwt","last_synced_at":"2026-04-14T23:32:33.343Z","repository":{"id":75531847,"uuid":"605275569","full_name":"valtech-commerce/jest-gwt","owner":"valtech-commerce","description":"Given-When-Then helper for Jest.","archived":false,"fork":false,"pushed_at":"2023-02-22T20:28:19.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-26T08:15:29.183Z","etag":null,"topics":["exception","given-when-then","gwt","jest","npm-package","package-json"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/valtech-commerce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-22T20:24:43.000Z","updated_at":"2023-02-22T20:31:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"cad545e0-01fc-4ef5-b4f4-8fba741b6db4","html_url":"https://github.com/valtech-commerce/jest-gwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/valtech-commerce/jest-gwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtech-commerce%2Fjest-gwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtech-commerce%2Fjest-gwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtech-commerce%2Fjest-gwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtech-commerce%2Fjest-gwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valtech-commerce","download_url":"https://codeload.github.com/valtech-commerce/jest-gwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtech-commerce%2Fjest-gwt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31819718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["exception","given-when-then","gwt","jest","npm-package","package-json"],"created_at":"2024-12-02T14:17:59.398Z","updated_at":"2026-04-14T23:32:33.301Z","avatar_url":"https://github.com/valtech-commerce.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @valtech-commerce/jest-gwt\n\n[![npm][npm-badge]][npm-url]\n[![npms.io: Score][npmsio-badge]][npmsio-url]\n[![libraries.io: SourceRank][librariesio-badge]][librariesio-url]\n[![Tests][tests-badge]][tests-url]\n[![License: MIT][license-badge]][license-url]\n\n\u003e [Given-When-Then](https://en.wikipedia.org/wiki/Given-When-Then) helper for [Jest](https://jestjs.io/).\n\n## Install\n\n```\n$ npm install @valtech-commerce/jest-gwt\n```\n\n## Usage\n\nImport the package in your Jest test files and extends the base GWT.\n\n```js\n//--------------------------------------------------------\n//  xyz.gwt.js\n//--------------------------------------------------------\nimport path from \"node:path\";\nimport { given as givenBase, when as whenBase, then as thenBase } from \"@valtech-commerce/jest-gwt\";\n\nconst given = { ...givenBase };\nconst when = { ...whenBase };\nconst then = { ...thenBase };\n\nlet rootPath;\n\ngiven.noRootPath = () =\u003e {\n\trootPath = undefined;\n};\n\ngiven.rootPath = (value) =\u003e {\n\trootPath = value;\n};\n\nwhen.packageIsLoaded = () =\u003e {\n\twhen.attempting(() =\u003e {\n\t\trequire(path.join(rootPath, \"package.json\"));\n\t});\n};\n\nexport { given, when, then };\n\n//--------------------------------------------------------\n//  xyz.test.js\n//--------------------------------------------------------\nimport { given, when, then } from \"./xyz.gwt\";\n\ndescribe(\"Validate package.json\", () =\u003e {\n\tbeforeEach(() =\u003e {\n\t\tgiven.noException();\n\t\tgiven.noRootPath();\n\t});\n\n\ttest(\"Ensure package can be loaded\", () =\u003e {\n\t\tgiven.rootPath(\"..\");\n\t\twhen.packageIsLoaded();\n\t\tthen.shouldNotHaveThrown();\n\t});\n});\n```\n\n## Helpers\n\nThe package comes with multiple helpers. If you want them all, import the root package `@valtech-commerce/jest-gwt`.\n\n### Exception `@valtech-commerce/jest-gwt/exception`\n\n\u003e Check for thrown exceptions\n\n#### `given.noException()`\n\nReset exception listener\n\n#### `when.attempting(closure: Function)`\n\nListen for error when executing closure\n\n#### `when.attemptingAsync(closure: Function)`\n\nListen for error when executing asynchronous closure\n\n#### `then.shouldHaveThrown()`\n\nException has been thrown\n\n#### `then.shouldHaveThrownMessageContaining(message: string)`\n\nException, with message excerpt, has been thrown\n\n#### `then.shouldNotHaveThrown(closure: Function)`\n\nNo exception has been thrown\n\n### Package `@valtech-commerce/jest-gwt/package`\n\n\u003e Tests for package.json\n\n#### `given.noPackageRoot()`\n\nReset root path\n\n#### `given.noPackageConfig()`\n\nReset parsed config\n\n#### `given.noPackageNamePattern()`\n\nReset name pattern\n\n#### `given.noPackageKeywords()`\n\nReset keywords\n\n#### `given.packageRoot(value: string)`\n\nSpecify the root path of the package.json\n\n#### `given.packageNamePattern(value: RegExp)`\n\nSpecify a pattern for the package name\n\n#### `given.packageKeywords(value: string[])`\n\nSpecify mandatory keywords\n\n#### `when.packageIsParsed()`\n\nParse the package.json file\n\n#### `then.packageNameShouldBeValid()`\n\nPackage name matches the defined name pattern\n\n#### `then.packageKeywordsShouldBeValid()`\n\nPackage keywords contain at least the defined keywords\n\n#### `then.packageExportsShouldExist()`\n\nPackage exports point to existing files\n\n## Documentation\n\nSee the [Changelog](CHANGELOG.md) to see what has changed.\n\n## Contribute\n\nSee the [Contributing Guidelines](CONTRIBUTING.md) for ways to get started.\n\nSee the [Support Guide](SUPPORT.md) for ways to get help.\n\nSee the [Security Policy](SECURITY.md) for sharing vulnerability reports.\n\nThis project has a [Code of Conduct](CODE_OF_CONDUCT.md).\nBy interacting with this repository, organization, or community you agree to abide by its terms.\n\n## License\n\n[MIT](LICENSE) © [Valtech Canada inc.](https://www.valtech.ca/)\n\n[npm-badge]: https://img.shields.io/npm/v/@valtech-commerce/jest-gwt?style=flat-square\n[npmsio-badge]: https://img.shields.io/npms-io/final-score/@valtech-commerce/jest-gwt?style=flat-square\n[librariesio-badge]: https://img.shields.io/librariesio/sourcerank/npm/@valtech-commerce/jest-gwt?style=flat-square\n[tests-badge]: https://img.shields.io/github/actions/workflow/status/valtech-commerce/jest-gwt/tests.yaml?style=flat-square\u0026branch=main\n[license-badge]: https://img.shields.io/badge/license-MIT-green?style=flat-square\n[npm-url]: https://www.npmjs.com/package/@valtech-commerce/jest-gwt\n[npmsio-url]: https://npms.io/search?q=%40valtech-commerce%2Fjest-gwt\n[librariesio-url]: https://libraries.io/npm/@valtech-commerce%2Fjest-gwt\n[tests-url]: https://github.com/valtech-commerce/jest-gwt/actions/workflows/tests.yaml?query=branch%3Amain\n[license-url]: https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaltech-commerce%2Fjest-gwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaltech-commerce%2Fjest-gwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaltech-commerce%2Fjest-gwt/lists"}