1

I am new to Mocha/Chai. I am working jQuery project. I have source files which are using the slick carousel library. I have following configuration on mocha file.

const fs = require('fs');
const path = require('path');

// I have added the slick.js here
const { slick } = require('../src/main/content/jcr_root/apps/mchp/clientlibs/vendor/resources/slick/slick');

const { JSDOM } = require('jsdom');
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');

const { window } = jsdom;
const { document } = window;

const $ = global.jQuery = require('jquery')(window);

global.window = window;
global.document = document;
global.$ = $;

After adding the slick file references I am getting an error like this. It is not even running any single test cases. But if I will comment out the slick reference then all test cases will pass. Only slick carousel related test cases will fail. Any help? Am I doing anything wrong?

✖ ERROR: window is not defined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mm_ui@1.0.0 test: `mocha './specs/*.spec.js' --require './specs/mocha- config.spec.js'`
npm ERR! Exit status 1
Richard Dallaway
  • 4,250
  • 1
  • 28
  • 39
Henry
  • 145
  • 4
  • 14
  • Any help here? https://stackoverflow.com/questions/34059644/mocha-command-giving-referenceerror-window-is-not-defined – Ed Lucas May 12 '20 at 19:56

0 Answers0