Javascript – testing read file with karma + PhantomJS

I need help from js expert.
I’v got a js file:

'use strict';

var fs = require('fs');

var Conf = {    
    read: read,
};

function read() {
    try {
        var conf = JSON.parse(fs.readFileSync(__dirname + '/../resources/conf.json', 'utf-8'));
        return conf;
    }
    catch (err) {
        console.log('There has been an error parsing your JSON.');
        console.log(err);
    }
}

module.exports = Conf;

I want to test it. I use karma + mocha. I created test file

'use strict';

var Conf = require('../../lib/Conf');

describe('My test', function() {

    describe('json config', function() {
        it('should display initially', function () {
            console.log(Conf.read());
        });
    });
});

But I always get TypeError error when run test with PhantomJS 2.1.1 if I change PhantomJS to Chrome I get undefined error.

Does test framework support require('fs');? If yes, help me, please to run it.

My karma config is

'use strict';
// Karma configuration
// Generated on Wed Mar 15 2017 00:21:08 GMT+0300 (RTZ 2 (зима))

module.exports = function (config) {
    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '../../',


        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['browserify', 'mocha', 'chai', 'sinon-chai'],


        // list of files / patterns to load in the browser
        files: [
            'test/spec/**/*Spec.js'
        ],


        // list of files to exclude
        exclude: [],


        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {'test/spec/**/*Spec.js': [ 'browserify' ]},


        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['spec'],


        // web server port
        port: 9876,


        // enable / disable colors in the output (reporters and logs)
        colors: true,


        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,


        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,


        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['PhantomJS'],


        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        browserify: {
            debug: true,
            transform: [ [ 'stringify', { global: true, extensions: [ '.bpmn', '.xml', '.css' ] } ] ]
        }
    })
}

my package.json dev deps

"devDependencies": {
    "brfs": "^1.2.0",
    "browserify": "^14.1.0",
    "chai": "^3.5.0",
    "grunt": "~1.0.1",
    "grunt-browserify": "^5.0.0",
    "grunt-contrib-connect": "~1.0.2",
    "grunt-contrib-copy": "~1.0.0",
    "grunt-contrib-jshint": "~1.0.0",
    "grunt-contrib-less": "^1.0.1",
    "grunt-contrib-watch": "~1.0.0",
    "grunt-karma": "^2.0.0",
    "karma": "^1.5.0",
    "karma-browserify": "^5.1.1",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-jasmine": "^1.1.0",
    "karma-mocha": "^1.3.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-sinon-chai": "^1.2.4",
    "karma-spec-reporter": "0.0.30",
    "load-grunt-tasks": "^3.5.2",
    "mocha": "^3.2.0",
    "sinon": "^1.17.7",
    "sinon-chai": "^2.8.0",
    "stringify": "^5.1.0"
  },


Source: stackoverflow-javascript