Skip to content

daggerok/jest-es2020-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jest es2020 Build Status

Testing es2020 features with jest...

quick one liner:

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

jest es6+

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

npm i -ED @jest/reporters jest-junit 

package.json

{
  "scripts": {
    "dev": "npm run test -- --watchAll",
    "test": "jest --reporters=default --reporters=jest-junit --collect-coverage"
  }
}

jest async / await

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

package.json

{
  "babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": {
            "node": "current"
          }
        }
      ]
    ]
  }
}

test/some.test.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

Releases

No releases published

Packages

No packages published