0

I have been trying to get a working wallaby.js configuration file for my meteor project and simply can't get it to work. I've borrowed from https://github.com/xolvio/automated-testing-best-practices and I have this currently:

const babel = require('babel-core')
const path = require('path')
const wallabyWebpack = require('wallaby-webpack')

module.exports = function (wallaby) {
  const webpackConfig = {
    resolve: {
      root: path.join(wallaby.projectCacheDir, 'imports'),
      extensions: ['', '.js', '.jsx', '.json']
    },
    module: {
      loaders: [
        // JavaScript is handled by the Wallaby Babel compiler
        { test: /\.json$/, loader: 'json-loader' }
      ]
    }
  }
  const wallabyPostprocessor = wallabyWebpack(webpackConfig)
  const appManifest = require(path.resolve('../.meteor/local/build/programs/web.browser/program.json')).manifest;
  const meteorPackageFiles = appManifest
    .filter(function (file) {
      return file.type === 'js' && file.path.startsWith('packages/')
    })
    .map(function (file) {
      /*      var basePath = packageStubs.indexOf(file.path) !== -1 ?
       'tests/client/stubs' :
       'src/.meteor/local/build/programs/web.browser';
       */
      var basePath = '../.meteor/local/build/programs/web.browser'
      return { pattern: path.join(basePath, file.path) }
    })

  return {
    files: [
      { pattern: '**/*.test.*', ignore: true },
      'startup/**/*.jsx',
      'startup/**/*.js'
    ].concat(meteorPackageFiles),
    tests: [
      '**/*.test.*'
    ],
    compilers: {
      '**/*.js*': wallaby.compilers.babel({
        babel,
        presets: ['react', 'es2015', 'stage-2']
      })
    },
    env: {
      type: 'node'
    },
    testFramework: 'mocha'
  }
}

This code successfully loads the startup files for the client-side, and the tests, but this simple test:

import should from 'should'
import buildRegExp from './buildregexp.js'

describe('buildRegExp', function() {
  it('splits on word characters', function() {
    buildRegExp('test this-thing:out').should.equal('(?=.*test)(?=.*this)(?=.*thing)(?=.*out).+')
  })
})

fails on line 1, because the npm module "should" is not found.

Does anyone have a working wallaby config or should I just give up?

meteor test --driver-package=practicalmeteor:mocha works, so the error is in the wallaby config.

Greg Beaver
  • 1,062
  • 11
  • 10
  • Perhaps you're missing setting `NODE_PATH`, like done in referenced repo: https://github.com/xolvio/automated-testing-best-practices/blob/master/wallaby_server.js#L14 – Artem Govorov Apr 25 '16 at 08:07
  • thanks for the reply! Actually, the referenced repo doesn't work either. I will try to make something simpler and figure out what is going on, then post wherever makes sense for you (I see you develop wallaby). Is here better or on the wallaby site? – Greg Beaver Apr 30 '16 at 02:58
  • Creating an issue in the repo is better https://github.com/wallabyjs/public/issues – Artem Govorov Apr 30 '16 at 07:30

0 Answers0