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

Setup configuration to multiple transpiled codebase #311

Closed
kwonoj opened this issue Oct 27, 2015 · 5 comments
Closed

Setup configuration to multiple transpiled codebase #311

kwonoj opened this issue Oct 27, 2015 · 5 comments

Comments

@kwonoj
Copy link

kwonoj commented Oct 27, 2015

Hi, I'm trying to setup wallaby on this repo where it's build script is currently configured as below:

"build_cjs": "... babel dist/es6 --out-dir dist/cjs --modules common --source-maps --loose all ...",
"build_es6": "... tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d",

(full script can be fount at package.json)

Due to several reason, this repo takes typescript source file into es6 build first, then create commonjs result from es6 transpiled build. Test cases are referencing final build of commonjs instead of es6.

How do I setup wallaby for this repo? I tried simple configuration such as beow (with atom plugin) but it wasn't successful.

module.exports = function (w) {
  return {
    files: [
      'src/**/*.ts'
    ],

    tests: [
      'spec/**/*-spec.js'
    ],

    compilers: {
      'src/Rx.ts src/Rx.KitchenSink.ts': w.compilers.typeScript({
        outDir: 'dist/es6',
        sourceMap: true,
        target: 2,
        declaration: true,
      })
    }
  };
};

Thanks in advance.

@ArtemGovorov
Copy link
Member

While it's possible to set up something like this, RxJs is using jasmine for node to run tests and wallaby.js does not yet support jasmine for node.js tests #2. I'll let you know once it's supported.

@kwonoj
Copy link
Author

kwonoj commented Oct 28, 2015

Thanks for confirmation. Actually spend some hrs after creating this issue, was about to spend more if I was not aware node.js with jasmine is yet supported. I'll wait for update.

@ArtemGovorov
Copy link
Member

@kwonoj Jasmine integration implementation is already in progress, and shouldn't take too long.

@ArtemGovorov
Copy link
Member

So Jasmine for node is ready - #21.
Re RxJS config, was tricky because of:

  • tests depend on compiled JavaScript, while wallaby as you know works differently, it shows everything right in the original source code;
  • the multistep process they have and just trying to compile their TS to ES5 didn't work;
  • some of the tests seem to depend on other tests (so have to constraint workers count).

but eventually I managed to get it working, here is the config:

module.exports = wallaby => ({
  files: [
    'index.js',
    'src/**/*.ts',
    {pattern: 'spec/helpers/test-helper.js', instrument: false}
  ],

  tests: ['spec/**/*-spec.js'],

  compilers: {
    '**/*.ts': wallaby.compilers.typeScript({
      module: 1,  // commonjs
      target: 2,  // ES6
      preserveConstEnums: true
    })
  },

  preprocessors: {
    '**/*.js': file => require('babel').transform(file.content, {sourceMap: true, loose: 'all'})
  },

  testFramework: 'jasmine',

  env: {
    type: 'node'
  },

  workers: {initial: 1, regular: 1},

  bootstrap: function (w) {
    // Remapping all require calls to `dist/cjs` right to `src`
    var Module = require('module').Module;
    if (!Module._originalRequire) {
      var modulePrototype = Module.prototype;
      Module._originalRequire = modulePrototype.require;
      modulePrototype.require = function (filePath) {
        return Module._originalRequire.call(this, filePath.replace('dist/cjs', 'src'));
      };
    }

    // Global test helpers
    require('./spec/helpers/test-helper');
  }
});

I'm planning to create a pull request to the original repo so that the repo contributors could use wallaby if they like.

@kwonoj
Copy link
Author

kwonoj commented Oct 29, 2015

Awesome, it works like charm :) appreciate for help!

image

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

2 participants