项目作者: daggerok

项目描述 :
JavaScript new features es2020
高级语言: JavaScript
项目地址: git://github.com/daggerok/whats-new-in-es2020.git
创建时间: 2020-05-06T21:16:52Z
项目社区:https://github.com/daggerok/whats-new-in-es2020

开源协议:

下载


what’s new in es2020 Build Status

Testing es2020 features with jest…

quick one liner:

  1. git clone --depth=1 --no-single-branch https://github.com/daggerok/whats-new-in-es2020 app && cd $_ && npm i && npm t

jest es6+

  1. mkdir app && cd $_
  2. npm init -y
  3. npm i -ED @babel/preset-env jest @jest/core @jest/globals @jest/types @types/jest @types/node

jest reporters

  1. npm i -ED @jest/reporters jest-junit

package.json

  1. {
  2. "scripts": {
  3. "dev": "npm run test -- --watchAll",
  4. "test": "jest --reporters=default --reporters=jest-junit --collect-coverage"
  5. }
  6. }

jest async / await

  1. npm i -ED @babel/preset-env core-js

package.json

  1. {
  2. "babel": {
  3. "presets": [
  4. [
  5. "@babel/preset-env",
  6. {
  7. "targets": {
  8. "node": "current"
  9. }
  10. }
  11. ]
  12. ]
  13. }
  14. }

test/some.test.js

  1. import { describe, it, expect } from '@jest/globals';
  2. describe('Dynamic Import', () => {
  3. it('should import lazy module dynamically', async () => {
  4. const dynamicModule = await import('../src/dynamic-module.js');
  5. const total = await dynamicModule.sum(1, 2, 3);
  6. await expect(total).toBe(6);
  7. });
  8. });

resources