@lwc/jest-preset
Jest preset configuration and stubs to help test LWC
Last updated 5 months ago by ekashida .
MIT · Original npm · Tarball · package.json
$ cnpm install @lwc/jest-preset 
SYNC missed versions from official npm registry.

@lwc/jest-preset

Tools to assist with testing Lightning Web Components (LWC) with Jest. This project provides 2 services: preset Jest configuration for testing Lightning web components, and stubs for common external libraries used in Lightning web components.

Usage

Jest Preset Configuration

  1. Install @lwc/synthetic-shadow. This is a polyfill for ShadowRoot that was tailor-made for LWC.

    yarn add --dev @lwc/synthetic-shadow

  2. Use this project's preset config. This maps to the settings in jest-preset.json. Any settings added to your project's own jest config will take precedence to entries in the preset.

    {
        "jest": {
            "preset": "@lwc/jest-preset"
        }
    }
    
  3. Update the moduleNameMapper entry in your Jest config to point to where your LWC components live. For example, use the following to map all components in the example and other namespaces:

    {
        "moduleNameMapper": {
            "^(example|other)/(.+)$": "<rootDir>/src/test/modules/$1/$2/$2"
        }
    }
    
  4. Create a __tests__ inside the bundle of the LWC component under test.

  5. Create a new test file in __tests__ that follows the naming convention <js-file-under-test>.test.js. See an example in this projects src/test directory.

  6. Write and run the Jest tests!

Current Tags

  • 0.34.7                                ...           218-patch (2 years ago)
  • 0.37.4-220.2                                ...           220-patch (a year ago)
  • 8.0.0-alpha4                                ...           canary (3 months ago)
  • 7.0.0                                ...           latest (5 months ago)
  • 0.35.1                                ...           master (2 years ago)
  • 9.0.0                                ...           next (10 days ago)
  • 0.34.7                                ...           spring-19 (2 years ago)
  • 0.37.4-220.2                                ...           summer-19 (a year ago)
  • 4.5.2-226.0                                ...           summer20 (5 months ago)
  • 0.40.1-222.1                                ...           winter-19 (a year ago)
  • 9.0.0-228.0                                ...           winter21 (10 days ago)

172 Versions

  • 9.0.0-228.0                                ...           10 days ago
  • 9.0.0                                ...           10 days ago
  • 8.0.0                                ...           3 months ago
  • 8.0.0-alpha4                                ...           3 months ago
  • 8.0.0-alpha3                                ...           3 months ago
  • 8.0.0-alpha2                                ...           3 months ago
  • 8.0.0-alpha1                                ...           3 months ago
  • 4.5.2-226.0                                ...           5 months ago
  • 7.0.0                                ...           5 months ago
  • 6.0.0                                ...           5 months ago
  • 5.0.1                                ...           5 months ago
  • 5.0.0                                ...           5 months ago
  • 4.5.2                                ...           6 months ago
  • 4.5.1                                ...           6 months ago
  • 4.5.0                                ...           6 months ago
  • 4.4.2                                ...           7 months ago
  • 4.4.1                                ...           7 months ago
  • 4.4.0                                ...           7 months ago
  • 4.3.1                                ...           9 months ago
  • 4.1.0-224.3                                ...           9 months ago
  • 4.1.0-224.2                                ...           9 months ago
  • 4.3.0                                ...           9 months ago
  • 4.1.0-224.1                                ...           9 months ago
  • 4.2.0                                ...           9 months ago
  • 4.2.0-alpha.0                                ...           9 months ago
  • 4.1.0-224.0                                ...           10 months ago
  • 4.1.0                                ...           10 months ago
  • 4.0.0                                ...           10 months ago
  • 4.0.0-alpha.0                                ...           10 months ago
  • 3.0.0                                ...           10 months ago
  • 3.0.0-alpha.12                                ...           10 months ago
  • 3.0.0-alpha.11                                ...           10 months ago
  • 3.0.0-alpha.10                                ...           10 months ago
  • 3.0.0-alpha.9                                ...           10 months ago
  • 3.0.0-alpha.8                                ...           10 months ago
  • 3.0.0-alpha.7                                ...           a year ago
  • 3.0.0-alpha.6                                ...           a year ago
  • 3.0.0-alpha.5                                ...           a year ago
  • 3.0.0-alpha.4                                ...           a year ago
  • 3.0.0-alpha.2                                ...           a year ago
  • 3.0.0-alpha.1                                ...           a year ago
  • 3.0.0-alpha.0                                ...           a year ago
  • 2.3.0-alpha1                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.1.1-alpha.0                                ...           a year ago
  • 2.1.0 [deprecated]           ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.1.0-alpha1                                ...           a year ago
  • 0.40.1-222.8                                ...           a year ago
  • 0.40.1-222.7                                ...           a year ago
  • 0.40.1-222.6                                ...           a year ago
  • 0.40.1-222.5                                ...           a year ago
  • 0.40.1-222.4                                ...           a year ago
  • 0.40.1-222.3                                ...           a year ago
  • 0.40.1-222.2                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 1.0.0-alpha.2                                ...           a year ago
  • 1.0.0-alpha.1                                ...           a year ago
  • 1.0.0-alpha.0                                ...           a year ago
  • 0.40.2-alpha.2                                ...           a year ago
  • 0.40.2-alpha1                                ...           a year ago
  • 0.40.1-ekashida1                                ...           a year ago
  • 0.40.1-222.1                                ...           a year ago
  • 0.40.1                                ...           a year ago
  • 0.40.1-alpha2                                ...           a year ago
  • 0.40.1-alpha1                                ...           a year ago
  • 0.40.0                                ...           a year ago
  • 0.39.1-222.4                                ...           a year ago
  • 0.37.4-220.2                                ...           a year ago
  • 0.39.1-222.3                                ...           a year ago
  • 0.37.4-220.1                                ...           a year ago
  • 0.39.2-alpha6                                ...           a year ago
  • 0.39.1-222.2                                ...           a year ago
  • 0.39.1-222.1                                ...           a year ago
  • 0.39.2-alpha2                                ...           a year ago
  • 0.39.2-alpha5                                ...           a year ago
  • 0.39.2-alpha1                                ...           a year ago
  • 0.37.4-alpha2                                ...           a year ago
  • 0.37.4-alpha1                                ...           a year ago
  • 0.37.4                                ...           a year ago
  • 0.37.3                                ...           a year ago
  • 0.39.1                                ...           a year ago
  • 0.38.2                                ...           a year ago
  • 0.38.2-alpha1                                ...           a year ago
  • 0.39.0                                ...           a year ago
  • 0.38.1-alpha1                                ...           a year ago
  • 0.38.1                                ...           a year ago
  • 0.38.0                                ...           a year ago
  • 0.38.0-alpha3                                ...           a year ago
  • 0.38.0-alpha2                                ...           a year ago
  • 0.38.0-alpha1                                ...           a year ago
  • 0.37.3-alpha10                                ...           a year ago
  • 0.37.3-alpha9                                ...           a year ago
  • 0.37.3-alpha8                                ...           a year ago
  • 0.37.3-alpha7                                ...           a year ago
  • 0.37.3-alpha6                                ...           a year ago
  • 0.37.3-alpha5                                ...           a year ago
  • 0.37.3-alpha4                                ...           a year ago
  • 0.37.3-alpha3                                ...           a year ago
  • 0.37.3-alpha2                                ...           a year ago
  • 0.37.3-alpha                                ...           a year ago
  • 0.37.2                                ...           a year ago
  • 0.34.8                                ...           a year ago
  • 0.37.1                                ...           a year ago
  • 0.37.0                                ...           2 years ago
  • 0.36.1                                ...           2 years ago
  • 0.36.0                                ...           2 years ago
  • 0.35.12                                ...           2 years ago
  • 0.36.0-beta4                                ...           2 years ago
  • 0.36.0-beta3                                ...           2 years ago
  • 0.36.0-beta2                                ...           2 years ago
  • 0.36.0-beta1                                ...           2 years ago
  • 0.35.11-test1                                ...           2 years ago
  • 0.34.7                                ...           2 years ago
  • 0.35.11                                ...           2 years ago
  • 0.36.0-alpha6                                ...           2 years ago
  • 0.36.0-alpha5                                ...           2 years ago
  • 0.35.10                                ...           2 years ago
  • 0.36.0-alpha4                                ...           2 years ago
  • 0.36.0-alpha3                                ...           2 years ago
  • 0.36.0-alpha2                                ...           2 years ago
  • 0.35.7-test1                                ...           2 years ago
  • 0.36.0-alpha1                                ...           2 years ago
  • 0.35.9                                ...           2 years ago
  • 0.34.6                                ...           2 years ago
  • 0.35.7                                ...           2 years ago
  • 0.35.7-alpha4                                ...           2 years ago
  • 0.35.7-alpha3                                ...           2 years ago
  • 0.34.5                                ...           2 years ago
  • 0.35.7-alpha2                                ...           2 years ago
  • 0.34.4                                ...           2 years ago
  • 0.35.6                                ...           2 years ago
  • 0.35.6-alpha1                                ...           2 years ago
  • 0.34.4-alpha1                                ...           2 years ago
  • 0.34.3                                ...           2 years ago
  • 0.35.5                                ...           2 years ago
  • 0.35.5-alpha-1                                ...           2 years ago
  • 0.34.2                                ...           2 years ago
  • 0.34.1                                ...           2 years ago
  • 0.35.4                                ...           2 years ago
  • 0.35.3                                ...           2 years ago
  • 0.35.2                                ...           2 years ago
  • 0.33.28-5                                ...           2 years ago
  • 0.33.28-4                                ...           2 years ago
  • 0.33.28-3                                ...           2 years ago
  • 0.33.28-2                                ...           2 years ago
  • 0.35.1                                ...           2 years ago
  • 0.34.0-alpha1                                ...           2 years ago
  • 0.35.0                                ...           2 years ago
  • 0.34.0                                ...           2 years ago
  • 0.33.28-alpha5                                ...           2 years ago
  • 0.33.28-alpha4                                ...           2 years ago
  • 0.33.28-1                                ...           2 years ago
  • 0.33.28-alpha3                                ...           2 years ago
  • 0.33.28-alpha2                                ...           2 years ago
  • 0.33.28-alpha1                                ...           2 years ago
  • 0.33.27-alpha2                                ...           2 years ago
  • 0.33.27-alpha1                                ...           2 years ago
  • 0.33.26                                ...           2 years ago
  • 0.33.25                                ...           2 years ago
  • 0.33.24                                ...           2 years ago
  • 0.33.23                                ...           2 years ago
  • 0.33.22                                ...           2 years ago
  • 0.33.21                                ...           2 years ago
  • 0.33.20                                ...           2 years ago
  • 0.33.19                                ...           2 years ago
  • 0.33.18                                ...           2 years ago
  • 0.33.10                                ...           2 years ago
  • 0.33.14                                ...           2 years ago
  • 0.33.13                                ...           2 years ago
  • 0.33.17                                ...           2 years ago
  • 0.33.17-alpha04                                ...           2 years ago

Copyright 2014 - 2016 © taobao.org |