{"id":26518843,"url":"https://github.com/feather-test/feather-test","last_synced_at":"2025-03-21T10:16:00.797Z","repository":{"id":57233964,"uuid":"70351226","full_name":"feather-test/feather-test","owner":"feather-test","description":"Extremely lightweight test coverage","archived":false,"fork":false,"pushed_at":"2018-03-28T17:36:26.000Z","size":108,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T14:24:07.352Z","etag":null,"topics":["assertions","automation","lightweight","testing","unit"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/feather-test.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-08T18:53:57.000Z","updated_at":"2018-05-01T18:00:14.000Z","dependencies_parsed_at":"2022-09-04T21:40:22.261Z","dependency_job_id":null,"html_url":"https://github.com/feather-test/feather-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feather-test%2Ffeather-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feather-test%2Ffeather-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feather-test%2Ffeather-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feather-test%2Ffeather-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feather-test","download_url":"https://codeload.github.com/feather-test/feather-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244566948,"owners_count":20473451,"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":["assertions","automation","lightweight","testing","unit"],"created_at":"2025-03-21T10:16:00.011Z","updated_at":"2025-03-21T10:16:00.776Z","avatar_url":"https://github.com/feather-test.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# feather-test\n\n\u003cimg src=\"https://travis-ci.org/feather-test/feather-test.svg?branch=master\"\u003e\u003c/img\u003e\n\n**Extremely lightweight JavaScript test coverage**\n\n*Refactor safely -- without configuring a burdensome test suite*\n\n\u003e Need to test JavaScript for browsers? Use [feather-test-browser](https://github.com/seebigs/feather-test-browser)\n\n## Install\n```\n$ npm install feather-test --save-dev\n```\n\n## Write Some Tests\n\n*myProject/test/specs/one.spec.js*\n```js\ndescribe('gizmo is a mogwai', function () {\n\n    describe('when you feed him after midnight', function () {\n\n        describe('he becomes a gremlin', function (expect) {\n            expect(skin).not.toBe('furry');\n            expect(temperament).toContain('angry');\n            expect(explosions).toBeGreaterThan(99, 'explosions caused by gremlins');\n        });\n\n    });\n\n});\n```\n\n*myProject/test/specs/two.spec.js*\n```js\n// example of an asynchronous test\ndescribe('teddy ruxpin is the creepiest bear ever', function () {\n\n    describe('he blinks twice every 3 seconds', function (expect, done) {\n        activateTeddy();\n        setTimeout(function () {\n            expect(timesBlinked).toBe(4);\n            done();\n        }, 6000);\n    });\n\n});\n```\n\n*myProject/package.json*\n```js\n{\n  \"scripts\": {\n    \"test\": \"node ./test/run\"    \n  }\n}\n```\n\n```\nmyProject/\n  |--test/\n  |  |--specs/\n  |  |  |--one.spec.js\n  |  |  |--two.spec.js\n  |  |--run.js\n  |--src/\n  |  |--etc.\n  |--package.json\n```\n\n## Run Your Tests\n*myProject/test/run.js*\n```js\nvar FeatherTest = require('feather-test');\n\n// create a new FeatherTest with your spec files\nvar myTests = new FeatherTest({\n    helpers: './helpers',\n    specs: './specs'\n});\n\n// run all queued tests by calling `run`\n// (optional callback will be executed after all tests finish)\nmyTests.run(callback);\n```\n\n```\n$ cd myProject\n$ npm test\n\n// All 4 tests passed!\n```\n\n---\n\n## Matchers\n*Any of the below can also be negated using not.toBe, etc.*\n\n- toBe\n- toBeGreaterThan\n- toBeLessThan\n- toContain\n- toEqual\n- toHaveBeenCalled\n- toHaveBeenCalledWith\n\n## Spec Methods\n*The following methods are globally available within spec files*\n\n### describe\nThe basic building block of specs. A description explains what features will be tested within. (can be nested)\n```js\ndescribe('some feature', function () {\n    describe('can do a thing', function (expect) {\n        expect(thing).toBe(true);\n    });\n});\n```\n\n### xdescribe\nSkips this block and all assertions within. Also skips nested describes.\n```js\nxdescribe('not right now', function (expect) {\n    expect(thisBlock).not.toBe('executed');\n});\n```\n\n### it, xit\nAlias for `describe` (above). Added to make migrations easier\n\n### any\nUse with matchers to indicate a match with and object that shares the same constructor\n```js\nexpect(result).toBe({\n    eventName: 'activated',\n    timestamp: any(Number)\n});\n```\n\n### clock\nManage timing events. Installing will add a global override for `setTimeout` and `setInterval`. To advance the clock use `clock.tick(amount)`.\n```js\ndescribe('overrides setTimeout when installed', function (expect) {\n    clock.install();\n\n    let happened = 0;\n    setTimeout(function () {\n        happened++;\n    }, 2000);\n\n    expect(happened).toBe(0);\n    clock.tick(2000);\n    expect(happened).toBe(1);\n\n    clock.uninstall();\n});\n```\n\n### spy\nStub or mock any function or method.\n\n`spy.on()` watches and counts each invocation.\n```js\ndescribe('no double agents here', function (expect) {\n    let obj = {\n        method: function () {\n            return 'original';\n        }\n    };\n\n    expect(obj.method()).toBe('original');\n\n    describe('put on your disguise', function (expect) {\n        spy.on(obj, 'method', function () {\n            return 'impostor';\n        });\n        expect(obj.method()).toBe('impostor');\n    });\n\n    // spies are reset after the containing describe is done\n    expect(obj.method()).toBe('original');\n});\n```\n`spy()` creates a new spy.\n```js\ndescribe('your secret training is complete', function (expect) {\n    let doubleOhSeven = spy(() =\u003e { return { license: 'kill'}; });\n    expect(doubleOhSeven().license).toBe('kill');\n    expect(doubleOhSeven).toHaveBeenCalled();\n});\n```\nPass a closured reference into async blocks to avoid having your spied functions reset.\n```js\nvar obj = {\n    method: function () {\n        console.log('original');\n    }\n};\n\ndescribe('test some stuff', function () {\n    describe('do something async', function () {\n        spy.on(obj, 'method', function () {\n            console.log('spied');\n        });\n        var spiedFn = obj.method; // save into a new reference that can be closured below\n        setTimeout(function () {\n            // must be used here as `spiedFn` not as `obj.method`\n            spiedFn(1); // output: \"spied\"\n        }, 10);\n    });\n    describe('do something async', function () {\n        obj.method(); // output: \"original\"\n    });\n});\n\n```\n\n---\n\n## Configuration Options\n`new FeatherTest(options)`\n\n### helpers\nFiles (or a directory of files) to load before your specs\n\n### specs\nThe files (or a directory of files) that contain your specs\n\n### beforeEach\nA function to execute before each describe\n\n### afterEach\nA function to execute after each describe\n\n### customMatchers\nAn array of matchers to add to the expect() return object\n```js\ncustomMatchers: [\n    {\n        name: 'toMatchCustom',\n        message: 'to match custom things',\n        matcher: function (expected, actual, utils) {\n            return expected === actual * 3;\n        }\n    }\n]\n```\n\n### stopAfterFirstFailure\nIf set to `true` specs will halt execution after the first spec fails\n\n### timeout\nHow long (in ms) to wait for an async describe to call `done()`\n\n## Build\n\nWe use Travis CI. Here's a link to the build: https://travis-ci.org/feather-test/feather-test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeather-test%2Ffeather-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeather-test%2Ffeather-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeather-test%2Ffeather-test/lists"}