AVA testing - configuring babel for transpiling sources


#1

I’m using AVA for testing in my Meteor app (METEOR@1.7.0.5). AVA automatically transpiles test files so no problem there. However, it doesn’t automatically transpile source files. The following recipe from the docs for configuring babel in package.json allows for transpiling source files:

{
	"ava": {
		"require": ["babel-register"]
	},
	"babel": {
		"presets": ["@ava/stage-4"]
	}
}

This works however as I understand it this could interfere with Meteor’s inbuilt babel configuration, right? Instead I’m using the following in my package.json:

{
  "ava": {
    "require": [
      "babel-register"
    ]
  },
  "babel": {
    "env": {
      "test": {
        "presets": [
          "@ava/stage-4"
        ]
      }
    }
  },
}

Using the env property here to configure transpiling for tests only should avoid any interferences with Meteor’s babel configuration, as Meteor sets to NODE_ENV to development and production in dev and prod respectively. Is my thinking correct here?

Also, instead of using the @ava/stage-4 preset how can I instead use the same configuration as meteor to ensure that the resulting transpiled sources used by tests are the same as how Meteor would transpile them?

For extra points, where can I find some more information about generally configuring babel in a Meteor app?