{"id":17772627,"url":"https://github.com/jamesplease/testing-with-babel","last_synced_at":"2025-04-01T15:21:19.403Z","repository":{"id":66133938,"uuid":"48701724","full_name":"jamesplease/testing-with-babel","owner":"jamesplease","description":"[Don't reference this]: Examples of using Babel with popular testing tools","archived":false,"fork":false,"pushed_at":"2015-12-30T20:57:53.000Z","size":36,"stargazers_count":48,"open_issues_count":10,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T09:41:58.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"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/jamesplease.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":"2015-12-28T16:34:18.000Z","updated_at":"2021-05-07T15:44:19.000Z","dependencies_parsed_at":"2023-02-20T00:30:36.987Z","dependency_job_id":null,"html_url":"https://github.com/jamesplease/testing-with-babel","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/jamesplease%2Ftesting-with-babel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesplease%2Ftesting-with-babel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesplease%2Ftesting-with-babel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesplease%2Ftesting-with-babel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesplease","download_url":"https://codeload.github.com/jamesplease/testing-with-babel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246660081,"owners_count":20813338,"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-26T21:40:08.813Z","updated_at":"2025-04-01T15:21:19.373Z","avatar_url":"https://github.com/jamesplease.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# testing-with-babel\n\n\u003e This is an active work-in-progress project. I plan to add 1-3 new\n\u003e configurations per day, so keep your eye on this project if you don't see\n\u003e what you're looking for!\n\nBabel is a fantastic tool for transpiling JavaScript, but it can be difficult\nto get it working with other tools in the Node ecosystem.\n\nPerhaps the most important set of tools to get working with Babel are unit\ntesting tools. I've spent a long time trying to figure out how to get Babel\nto work with these tools – scouring GitHub issues, reading blog posts, and\nexperimenting on my own – and everything that I've learned will be posted\nhere.\n\nAm I missing a testing test up that you'd like to see?\n[Make a request](https://github.com/jmeas/testing-with-babel), or better yet,\nsubmit a PR!\n\n#### How it works\n\nThis repository is a collection of examples which all live in the `examples`\ndirectory. Every example has a README that explains how to get it\nset up locally, and then steps through how it works.\n\nTo begin, you'll want to clone this repository. You can then either browse\nthrough the list of examples in the `examples` directory, or in the table\nof contents below.\n\n#### What presets of Babel are used?\n\nAll of the examples in this project use only the\n[ES2015 preset](http://babeljs.io/docs/plugins/preset-es2015/). This is because\nthis is the preset that the vast majority of people will care about: it's the\none that lets you author things in ES2015.\n\nIn the future, I plan to add some data around which set ups allow you to use\nadditional presets, like, say, `stage-2`. In the meantime, you can test on your\nown the support for those presets.\n\n#### Node-only Examples\n\nThese examples are suitable for libraries that you wish to test in Node only.\n\n**Without code coverage**\n\n- [Mocha + Chai, run on the CLI](examples/mocha-cli)\n- [Mocha + Chai + Gulp](examples/mocha-gulp)\n- [Mocha + Chai + Grunt](examples/mocha-grunt)\n\n**With code coverage**\n\n- [Mocha + Chai + Istanbul, run on the CLI](examples/mocha-istanbul-cli)\n- [Mocha + Chai + Istanbul + Gulp](examples/mocha-istanbul-gulp)\n\n#### Browser-only Examples\n\nThese are good for tests that you only want to run in browser environments,\nand not Node.\n\n*Coming soon*\n\n#### Browser + Node environments\n\nThis section are examples showing how to run the tests in a browser and in Node.\n\n*Coming soon*\n\n### FAQ\n\n**Are there any limitations to using Istanbul with Babel?**\n\nYes. The tool isparta is used to make Istanbul work with transpiled code, and\nby and large it works great. The coverage report will look like your original\nES2015 code, and report accurately on the `lines` that are covered.\n\nHowever, every other property that Istanbul measures will *still* be based on\nthe transpiled code. So the `statements`, `branches`, and `functions`\nmeasurements will be based off of the code that Babel computes.\n\nI haven't found this to be a problem on any of my projects, because I use\ncode coverage as a tool to give me an idea of how complete my test coverage is.\nThe approximation provided to me by using it with ES2015 is equally good for\naccomplishing that goal.\n\nHowever, if you're someone who requires that the coverage data be more precise,\nthen you may want to shy away from Babel for now (or update isparta to be\nmore accurate!)\n\n#### To-do\n\n##### Node only\n\n- Mocha\n  - [x] CLI\n  - [x] Gulp\n  - [x] Grunt\n- Mocha + Istanbul\n  - [x] CLI\n  - [x] Gulp\n  - [ ] Grunt\n- Mocha + JSDom\n  - [ ] CLI\n  - [ ] Gulp\n  - [ ] Grunt\n- Mocha + Istanbul + JSDom\n  - [ ] CLI\n  - [ ] Gulp\n  - [ ] Grunt\n\n##### Browser only\n\n- [ ] Mocha + Runner HTML file\n- [ ] Mocha + PhantomJS CLI\n- [ ] Mocha + PhantomJS + Runner HTML file\n- [ ] Mocha + Karma (no coverage)\n- [ ] Mocha + Karma (with coverage)\n- [ ] Mocha + Karma (without coverage) + Runner HTML File\n- [ ] Mocha + Karma (with coverage) + Runner HTML File\n\n##### Node + Browser\n\n- Mocha/Chai + Karma\n  - [ ] CLI\n  - [ ] Gulp\n  - [ ] Grunt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesplease%2Ftesting-with-babel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesplease%2Ftesting-with-babel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesplease%2Ftesting-with-babel/lists"}