Skip to content

Why transpile to files instead of in memory?

Operations Research Engineering Software+ edited this page Dec 25, 2017 · 3 revisions

Suman has full support for both in-memory and disk transpilation for JS based tests. Suman does not have a preference, but in general Suman may encourage developers to transpile test source to disk.

There are at least 3 good reasons for this:

  1. If you have already transpiled the file, and the source files haven't changed since, then you don't need to transpile again! Saves time when executing the tests. This is a big one :) In other words, maybe your application code has changed, but your test source hasn't. So just run the test target files, without re-transpiling them.

  2. Transpiled test files on disk helps you debug, in this case of transpilation issues, etc. Babel, TypeScript, etc, are still not perfect.

  3. Code coverage - you will want/need to run Istanbul against your target files instead of source files.

On the other hand, the advantages of in-memory are significant. The biggest advantage is:

  1. By monkey-patching require(), babel-register and ts-node can ensure all relevant files get transpiled. It can be difficult to ensure all source gets included and transpiled when writing target files to disk.

Docs

Clone this wiki locally