I write tests on CoffeeScript with using Webdriver.io and mocha. Code processed by the CoffeeScript compiler.
In the project I'm developing, it was decided to switch to syntax ES6. To ensure that the code written earlier is supported, the Babel compiler has been connected, which converts unsupported syntax (such as import) to supported syntax (require). But Mocha does not provide for the possibility of the running two compilers simultaneously (at least, I found this information in the network).
Certainly, a workaround is to compile the files using the CoffeeScript compiler, save them to a temporary folder, and configure Mocha with the Babel compiler so that Babel compiles the converted files from the temporary folder:
coffee-with test/*.coffee
mocha compilers js: babel-core / register
But this is not the most beautiful decision: you have to use two commands instead of one, monitor the folder with temporary files and so on. I would like to somehow perform CoffeeScript files with Babel in one command without using temporary folders and files. So far, all information I found in the Internet comes down to the fact that it is impossible (about such information https://github.com/jashkenas/coffeescript/issues/4969 I came across repeatedly). But maybe there are ways?
Basic information on this issue was found here: https://www.npmjs.com/package/coffee-babel. The NPM coffee-babel package solves the described problem.
The only package: for the package to work correctly in the wdio.conf.js file in the settings of the Mocha compiler, you need to connect the coffee-babel package. This is done as follows:
mochaOpts: {
...
...
require: ['coffee-babel'],
}