https://github.com/daggerok/whats-new-in-es2020
JavaScript new features es2020
https://github.com/daggerok/whats-new-in-es2020
es2020 jest jest-reporter jest-test jest-tests
Last synced: 7 months ago
JSON representation
JavaScript new features es2020
- Host: GitHub
- URL: https://github.com/daggerok/whats-new-in-es2020
- Owner: daggerok
- Created: 2020-05-06T21:16:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-06T23:22:24.000Z (over 5 years ago)
- Last Synced: 2025-01-10T00:37:18.768Z (9 months ago)
- Topics: es2020, jest, jest-reporter, jest-test, jest-tests
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# what's new in es2020 [](https://travis-ci.org/daggerok/whats-new-in-es2020)
Testing es2020 features with jest...quick one liner:
```bash
git clone --depth=1 --no-single-branch https://github.com/daggerok/whats-new-in-es2020 app && cd $_ && npm i && npm t
```## jest es6+
```bash
mkdir app && cd $_
npm init -y
npm i -ED @babel/preset-env jest @jest/core @jest/globals @jest/types @types/jest @types/node
```## jest reporters
```bash
npm i -ED @jest/reporters jest-junit
```_package.json_
```json
{
"scripts": {
"dev": "npm run test -- --watchAll",
"test": "jest --reporters=default --reporters=jest-junit --collect-coverage"
}
}
```## jest async / await
```bash
npm i -ED @babel/preset-env core-js
```_package.json_
```json
{
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
}
```_test/some.test.js_
```js
import { describe, it, expect } from '@jest/globals';describe('Dynamic Import', () => {
it('should import lazy module dynamically', async () => {
const dynamicModule = await import('../src/dynamic-module.js');
const total = await dynamicModule.sum(1, 2, 3);
await expect(total).toBe(6);
});
});
```## resources
* https://jestjs.io/docs/en/tutorial-async#asyncawait
* https://github.com/facebook/jest/blob/master/examples/async/.babelrc.js
* https://jestjs.io/docs/en/cli
* https://www.freecodecamp.org/news/javascript-new-features-es2020/
* https://medium.com/@dtkatz/use-the-blazing-fast-parcel-bundler-to-build-and-test-a-react-app-e6972a2587e1