{"id":20490846,"url":"https://github.com/osoco/introducing-jest","last_synced_at":"2026-03-10T05:31:03.211Z","repository":{"id":80162415,"uuid":"198453755","full_name":"osoco/introducing-jest","owner":"osoco","description":"Introducing Jest","archived":false,"fork":false,"pushed_at":"2019-07-23T16:26:24.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-05T17:32:48.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/osoco.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-23T15:03:55.000Z","updated_at":"2019-07-23T16:26:26.000Z","dependencies_parsed_at":"2023-03-16T14:30:16.331Z","dependency_job_id":null,"html_url":"https://github.com/osoco/introducing-jest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/osoco/introducing-jest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoco%2Fintroducing-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoco%2Fintroducing-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoco%2Fintroducing-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoco%2Fintroducing-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osoco","download_url":"https://codeload.github.com/osoco/introducing-jest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osoco%2Fintroducing-jest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30326056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"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":[],"created_at":"2024-11-15T17:18:43.115Z","updated_at":"2026-03-10T05:31:03.170Z","avatar_url":"https://github.com/osoco.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introducing Jest\n## 1. Prerequisites\n- Install *node*  https://nodejs.org/en/download/  \n```bash\n$ node -v\nv10.16.0\n```\n- Install and *npm* https://www.npmjs.com/get-npm\n```bash\n$ npm -v\n6.9.0\n```\n\n## 2. Creating a Node Project\n```bash\n$ mkdir tdd-roman-numerals-kata\n$ cd tdd-roman-numerals-kata\n```\n\n### 2.1. Create *package.json* with `npm init`.   \nPress ↩️ at each prompt to accept the default response\n\n```bash\n$ npm init\n...\npackage name: (tdd-roman-numerals-kata) \nversion: (1.0.0) \ndescription: \nentry point: (index.js) \ntest command: \ngit repository: \nkeywords: \nauthor: \nlicense: (ISC) \n...\nIs this OK? (yes)\n```\nAdd `\"private\": true` to *package.json* to npm will refuse to publish it (this is a way to prevent accidental publication of private repositorie)\n\n### 2.2. Add Jest as Dependency  \nUse npm to install the jest package\n ```bash\n$ npm install --save-dev jest@24.8.0\nnpm notice created a lockfile as package-lock.json. You should commit this file.\n+ jest@24.8.0\nadded 479 packages from 344 contributors and audited 873786 packages in 12.856s\nfound 0 vulnerabilities\n```\n## 3. Running Package Binaries with npx\nnpm is a package manager, npx is a package runner.        \n```bash\n$ npx jest\nNo tests found, exiting with code 1\nRun with `--passWithNoTests` to exit with code 0\nIn ~/tdd-roman-numerals-kata\n  2 files checked.\n  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches\n  testPathIgnorePatterns: /node_modules/ - 2 matches\n  testRegex:  - 0 matches\nPattern:  - 0 matches\n```\n```bash\n$ npx jest --version\n24.8.0\n```\n## 4. Running Project Scripts with npm\nThe best way to do that is to list those commands in the scripts section of your project’s `package.json`.\n```json\n{\n  \"name\": \"tdd-roman-numerals-kata\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"jest\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"jest\": \"^24.8.0\"\n  }\n}\n```        \n```bash\n$ npm test\n\u003e tdd-roman-numerals-kata@1.0.0 test ~/tdd-roman-numerals-kata\n\u003e jest\n\nNo tests found, exiting with code 1\nRun with `--passWithNoTests` to exit with code 0\nIn ~/tdd-roman-numerals-kata\n  2 files checked.\n  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches\n  testPathIgnorePatterns: /node_modules/ - 2 matches\n  testRegex:  - 0 matches\nPattern:  - 0 matches\nnpm ERR! Test failed.  See above for more details.\n```\n\n## 5. Writing a test\nCreate a file called *src/tests/romanNumerals.test.js* :\n```js\nconst arabicToRoman = arabic =\u003e `I`;\n\ndescribe('arabicToRoman()', () =\u003e {\n  it('convert number one', () =\u003e {\n    expect(arabicToRoman(1)).toBe('I');\n  });\n});\n```\nRun all tests with:\n```bash\n$ npm test\n...\n PASS  src/tests/romanNumerals.test.js\n  arabicToRoman()\n    ✓ convert number one (2ms)\n\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        0.624s, estimated 1s\nRan all test suites.\n```\n\n## 6. Test-Driven Development\n### 6.1. Starting from Failure\nCreate *src/romanNumerals.js* file:\n```js\nmodule.exports = (number) =\u003e 'I';\n```\nAnd chage the *src/tests/romanNumerals.test.js*:\n```js\nconst arabicToRoman = require('../romanNumerals');\n\ndescribe('arabicToRoman()', () =\u003e {\n  it('convert number one', () =\u003e {\n    expect(arabicToRoman(1)).toBe('I');\n  });\n  it('convert number two', () =\u003e {\n    expect(arabicToRoman(2)).toBe('II');\n  });\n});\n```\n### 6.2. Running Jest Tests Automatically\n```bash\n$ npx jest --watchAll\n```\n### 6.3 Measuring Test Coverage\n```bash\n$ npm run test -- --coverage --coverageReporters=text\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosoco%2Fintroducing-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosoco%2Fintroducing-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosoco%2Fintroducing-jest/lists"}