{"id":22061685,"url":"https://github.com/floofies/js-test","last_synced_at":"2025-03-23T17:27:48.079Z","repository":{"id":228906823,"uuid":"774629685","full_name":"Floofies/js-test","owner":"Floofies","description":"Low budget expect-based unit tests. Isolates between invocations and safely contains everything that can go wrong.","archived":false,"fork":false,"pushed_at":"2024-03-21T19:04:50.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T23:28:34.394Z","etag":null,"topics":["bdd","expect","testing","unit-test"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Floofies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-19T22:13:34.000Z","updated_at":"2024-03-22T20:47:46.000Z","dependencies_parsed_at":"2024-03-21T03:32:00.353Z","dependency_job_id":"cd22ef7c-b995-48e8-b846-6da2e33464de","html_url":"https://github.com/Floofies/js-test","commit_stats":null,"previous_names":["floofies/js-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2Fjs-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2Fjs-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2Fjs-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2Fjs-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Floofies","download_url":"https://codeload.github.com/Floofies/js-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245139160,"owners_count":20567115,"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":["bdd","expect","testing","unit-test"],"created_at":"2024-11-30T18:13:59.086Z","updated_at":"2025-03-23T17:27:48.049Z","avatar_url":"https://github.com/Floofies.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-test\n\nLow budget expect-based unit tests. Isolates between invocations and safely contains everything that can go wrong.\n\n# Usage\n\n1. Import and instantiate the `UnitTest` class.\n2. Invoke method `test`, supply a description and callback with an `expect` parameter.\n3. Invoke the supplied `expect` function, supply the test data.\n4. Invoke the BDD testing methods of the returned object.\n\n```JS\nimport UnitTest from \"js-test\";\n\nconst myTest = new UnitTest();\n\nconst testPromise = myTest.test(\"My Test\", expect =\u003e {\n\texpect(2+2).toBe(4);\n\texpect(2+2).toNotBe(5);\n});\n\ntestPromise.then(testStatus =\u003e {\n\tif(testStatus)\n\t\tconsole.log(\"Test passed!\");\n\telse\n\t\tconsole.log(\"Test failed!\");\n});\n```\n\nConsole output:\n\n```\nTest \"My Test\":\n        ƒ Test started 2024-03-21T02:35:44.098Z\n        ✓ Test PASSED in 0.081ms\n\nTest passed!\n```\n\n# `UnitTest` Class\n\n```JS\nnew UnitTest();\n```\n\nThe class `UnitTest` is used to execute tests, organize test settings, and store test logs.\n\n## Instance Methods\n\n### `UnitTest.prototype.test` Method\n\n```JS\ntest( description: string, testFunction: (expect) =\u003e any ): Promise\u003cboolean\u003e\n```\n\nCalls the given `testFunction` function and supplies an `expect` function as the input parameter.\n\nReturns a Promise which resolves to a boolean which indicates if the test passed or failed.\n\n`expect` returns a new `Expectation` class instance. (See [Expectation Class](#expectation-class)).\n\nHere is an example of a valid `testFunction`:\n\n```JS\nfunction(expect) {\n\texpect(anyValue).toBe(anyValue);\n}\n```\n\n## Instance Properties\n\n### `history` Property\n- Type `string[][]`\n\nThe `history` property contains logs of past tests. Is an Array which contains Arrays of strings.\n\n### `emit` Property\n- Type `boolean`\n- *Default = `true`*\n\nThe `emit` property is a boolean which ndicates if test progress and results should be logged to console.\n\n# Expectation Class\n\n```JS\nnew Expectation(anyValue: any);\n```\n\nThe test callback is supplied with an `expect` factory function which returns an `Expectation` instance.\n\n## Instance Properties\n\n### `actualValue` Property\n\n- Type: `any`\n \nThe value given to `expect`, regarded as the \"actual data\" and not the expected data.\n\n## Instance Methods\n\nEach of the following methods throws an `ExpectError` when its condition fails:\n\nMethod|Expect Input|Method Input|Condition Description\n---|---|---|---\n`toBe`|any|any|Passes based on the expected value being strictly equivalent to the given value.\n`toNotBe`|any|any|Opposite of `toBe`. Passes based on the expected value being strictly equivalent to the given value.\n`toReturn`|Function|any|Passes based on the expected function return value being strictly equivalent to the given value.\n`toNotReturn`|Function|any|Opposite of `toReturn`. Passes based on the expected function not returning the given value, or none at all.\n`toThrow`|Function|any|Passes based on the expected function throwing an instance of the given error, or at all.\n`toNotThrow`|Function|any|Opposite of `toThrow`. Passes based on the expected function not throwing an instance of the given error, or none at all.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloofies%2Fjs-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloofies%2Fjs-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloofies%2Fjs-test/lists"}