Code Monkey home page Code Monkey logo

jest-transform-yaml's Introduction

jest-transform-yaml

A Jest transformer that allows the import of YAML files

Description

When you store your data in YAML format for your application, you might want to import that data within your Jest tests. By default, Jest does not know how to import YAML files, so you will need to provide a transformer that can properly load it.

Installation

NOTE: I generally recommend saving exact dependencies to avoid accidental/unintentional updates, hence the added flags below.

# NPM
npm install jest-transform-yaml --save-dev

# Yarn
yarn add jest-transform-yaml --dev --exact

# PNPM
pnpm add jest-transform-yaml --save-dev --save-exact

Usage

In your jest.config.js (or jest.config.ts) file, add the following:

module.exports = {
    // ...
    transform: {
        // ... other transforms ...
        "\\.yaml$": "jest-transform-yaml",
    },
    "moduleFileExtensions": [
        // .. other file extensions ... 
        "yaml"
    ],
    // ...
}

Node support

Currently, this is set up to be tested against all Node LTS versions and the current. If you observe an issue within your project around Node version support, please feel free to raise a PR or add an issue ๐Ÿ˜„

Alternatives

jest-transform-yaml's People

Contributors

sumwatshade avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Forkers

kamihq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.