How to Load a File for Testing with Jasmine Node?

前端 未结 3 1453
-上瘾入骨i
-上瘾入骨i 2021-02-04 01:02

I have a simple JavaScript file, color.js, and a matching spec file, colorSpec.js.

color.js:

function Color()          


        
3条回答
  •  无人共我
    2021-02-04 01:19

    This is not how require works. Your color.js needs to define/export something. I will assume you use require.js here for sanity.

    color.js

    define('Color', function (require) {
      var Color = function () {};
      return Color;
    });
    

    Then in your spec:

    var Color = require('color.js');
    

提交回复
热议问题