{"id":16641385,"url":"https://github.com/cmstead/fluent-gwt","last_synced_at":"2025-07-05T20:03:34.265Z","repository":{"id":44211915,"uuid":"243096268","full_name":"cmstead/fluent-gwt","owner":"cmstead","description":"A native JS fluent Given/When/Then library for improving BDD test structure","archived":false,"fork":false,"pushed_at":"2022-12-30T19:45:12.000Z","size":166,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T15:24:51.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmstead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-25T20:31:59.000Z","updated_at":"2020-03-07T05:58:26.000Z","dependencies_parsed_at":"2023-01-31T14:50:12.016Z","dependency_job_id":null,"html_url":"https://github.com/cmstead/fluent-gwt","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Ffluent-gwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Ffluent-gwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Ffluent-gwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmstead%2Ffluent-gwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmstead","download_url":"https://codeload.github.com/cmstead/fluent-gwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243159166,"owners_count":20245675,"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-10-12T07:46:23.747Z","updated_at":"2025-03-12T05:17:24.263Z","avatar_url":"https://github.com/cmstead.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fluent-GWT #\n\nFluent-GWT is a native-Javascript Given/When/Then library which integrates into node test flows. The API helps codify the G/W/T or Arrange/Act/Assert workflow in your tests, making it easier to understand which part of the test is accomplishing what work.\n\nFluent-GWT provides extra helping information when tests fail, by logging which section of the test generated the error. This reduces time spent searching for the misbehaving code.\n\n**Why Another GWT Library?**\n\nThough Jasmine-Given, Mocha-Given, and Mocha-GWT exist, they all require, at the very least, a parser/interpreter and a new language in the toolchain.  This makes them hard to integrate into current testing solutions and unfriendly if users are already feeling tooling fatigue. Fluent-GWT aims to simplify this problem and improve testing for people who aren't comfortable with the extra build tooling.\n\n## Setup ##\n\nInstall with npm:\n\n```npm install fluent-gwt --save-dev```\n\n## Usage ##\n\nFluent-GWT can be used by requiring it into your test file (node) -- client test are currently unsupported.\n\nRequiring in node looks like this:\n\n```javascript\nconst gwt = require('fluent-gwt')\n    .configure({\n        verbose: true // default is false\n    });\n```\n\nBelow is an example of a test using Fluent-GWT (used in Mocha):\n\n```javascript\nit('tests a behavior when a user defines a simple, synchronous test', function () {\n    return gwt\n        .given(\n            'User event is described and has an initial state',\n            () =\u003e 'test string'\n        )\n        .when(\n            'Behavior is called, capture outcome',\n            (valueToUse) =\u003e valueToUse + ': success'\n        )\n        .then(\n            'Outcome should match expectation',\n            (outcomeToTest) =\u003e assert.equal(outcomeToTest, 'test string: success')\n        );\n});\n```\n\nFluent-GWT supports Arrange/Act/Assert (otherwise known as A/A/A or triple-A) style test setup:\n\n```javascript\nit('works as expected when arrange/act/assert is preferred by the user', function () {\n    return gwt\n        .arrange(\n            'a promise-returning function is used',\n            () =\u003e Promise.resolve('async string')\n        )\n        .act(\n            'an asynchronous when is used',\n            (givenResult) =\u003e Promise.resolve(givenResult)\n        )\n        .assert(\n            'the async string should pass through',\n            (actualResult) =\u003e assert.equal(actualResult, 'async string')\n        )\n});\n```\n\nFluent-GWT also supports callback-resolving functions this way:\n\n```javascript\nit('supports callback-style behaviors when a user needs to', function () {\n    return gwt\n        .given(\n            'a promise-returning function is used',\n            // gwt.fromCallback converts the callback-resolving function\n            // into something Fluent-GWT can use\n            gwt.fromCallback(callback =\u003e callback(null, 'callback string'))\n        )\n        .when(\n            'an asynchronous when is used',\n            (givenResult) =\u003e Promise.resolve(givenResult)\n        )\n        .then(\n            'the async string should pass through',\n            (actualResult) =\u003e assert.equal(actualResult, 'callback string')\n        )\n});\n```\n\nFluent-GWT is promise-returning, so you can always \"then\" or \"catch\" against it:\n\n```javascript\nit('provides GWT output when a test fails', function () {\n    return gwt\n        .given(\n            'User event is described and has an initial state',\n            () =\u003e 'test string'\n        )\n        .when(\n            'Behavior is called, capture outcome',\n            (valueToUse) =\u003e valueToUse + ': success'\n        )\n        .then(\n            'Outcome should match expectation',\n            () =\u003e {\n                throw new Error('This test failed because reasons');\n            })\n\n        .then(function () {\n            assert.isFalse(true);\n        })\n        .catch(function (error) {\n            const failureMessage = 'Test failed:\\n\\n' +\n                'Given: User event is described and has an initial state\\n' +\n                'When: Behavior is called, capture outcome\\n' +\n                'Then: Outcome should match expectation\\n' +\n                '\\n' +\n                'Error message: This test failed because reasons'\n\n            assert.equal(error.message, failureMessage);\n        });\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmstead%2Ffluent-gwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmstead%2Ffluent-gwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmstead%2Ffluent-gwt/lists"}