Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for babel env option #14

Open
bashar-qassis opened this issue Mar 10, 2020 · 0 comments
Open

Support for babel env option #14

bashar-qassis opened this issue Mar 10, 2020 · 0 comments

Comments

@bashar-qassis
Copy link

bashar-qassis commented Mar 10, 2020

I'm in a case where tests and source code are both using imports (ES6 syntax). pectin wants modules to be set to false while mocha want them to be true.
Babel supports multiple envs in the babelrc config file, so supporting it in pectin would be great.

I'm currently using node v13.10.1, babel 6 and pectin ^3.6.1

PS: any other suggestions for me to do this in a "better" way are also welcome 😊

.babelrc file

{
  "env": {
    "test": {
      "presets": [
        [
          "env",
          {
            "targets": {
              "node": "current"
            }
          }
        ]
      ]
    },
    "build": {
      "presets": [
        [
          "env",
          {
            "modules": false,
            "targets": {
              "node": "current"
            }
          }
        ]
      ]
    }
  }
}

sample app.js

export function foo () {
    return 'bar'
}

sample test.spec.js

import { foo } from '../src/app'

describe('testing app', () => {
    it('should return bar', function () {
        expect(foo()).to.deep.equal('bar')
    })
})

mocha.opts

--require babel-core/register
--require babel-register
--require test/setup.js
--recursive

source: https://babeljs.io/docs/en/6.26.3/babelrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant