wallaby.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const babel = require('babel-core')
  2. module.exports = function (wallaby) {
  3. return {
  4. files: [
  5. {
  6. pattern: 'package.json',
  7. instrument: false
  8. },
  9. {
  10. pattern: 'config.tpl.js',
  11. instrument: false
  12. },
  13. {
  14. pattern: 'test/unit/certificates/server.key',
  15. instrument: false
  16. },
  17. {
  18. pattern: 'test/unit/certificates/server.crt',
  19. instrument: false
  20. },
  21. {
  22. pattern: 'test/unit/**/*.spec.js',
  23. ignore: true
  24. },
  25. 'lib/**/*.js',
  26. 'test/unit/**/*.js',
  27. 'test/unit/mocha-globals.js'
  28. ],
  29. tests: [
  30. 'test/unit/**/*.spec.js'
  31. ],
  32. compilers: {
  33. '**/*.js': wallaby.compilers.babel({
  34. babel: babel
  35. })
  36. },
  37. bootstrap: function (w) {
  38. var path = require('path')
  39. var mocha = w.testFramework
  40. mocha.suite.on('pre-require', function () {
  41. // always passing wallaby.js globals to mocks.loadFile
  42. var mocks = require('mocks')
  43. var loadFile = mocks.loadFile
  44. mocks.loadFile = function (filePath, mocks, globals, mockNested) {
  45. mocks = mocks || {}
  46. globals = globals || {}
  47. globals.$_$wp = global.$_$wp || {}
  48. globals.$_$wpe = global.$_$wpe || {}
  49. globals.$_$w = global.$_$w || {}
  50. globals.$_$wf = global.$_$wf || {}
  51. globals.$_$tracer = global.$_$tracer || {}
  52. return loadFile(filePath, mocks, globals, mockNested)
  53. }
  54. // loading mocha-globals for each run
  55. require(path.join(process.cwd(), 'test/unit/mocha-globals'))
  56. })
  57. },
  58. env: {
  59. type: 'node',
  60. params: {
  61. runner: '--harmony --harmony_arrow_functions'
  62. }
  63. }
  64. }
  65. }