Skip to content

badico-cloud-hub/babel-plugin-reflective-import

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Babel Plugin Relative Import

Import files for tests as easy if they are in the same folder as the tested. give your folder structure

src/
  component/
   fileTotest.js

__tests__/
  component/
    fileTotest.test.js

in your fileTotest.test.js

import componentTotest from '$/fileTotest.js';
// Gets compiled to:
import fooHelper from '../../src/fileTotest.js';
// No more unecessarie paths!

Quickstart

npm install babel-plugin-relative-import --save-dev

Add a .babelrc file and write:

{
  "plugins": [
    "babel-plugin-reflexive-import"
  ]
}

Options

You can use a custom root with the testPathFolder option. And you can set the off set between your source and test.

{
  "plugins": [
    ["babel-plugin-relative-import", {
      "testFolder": "__tests__",
      "srcFolder": "src"
    }]
  ]
}

Inspiration

Inspired by the babel-relative-import from Olivier Louvignes.

About

Import made easy for __tests__

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%