mocha - Is DB a reserved word in Node.js -


i building tests mocha , chai(expect). keeping simple learning testing methodology go along.

i have mysql db layer in config file. testing db parameters, ran weird issue.

these db parameters test fine:

host= 'localhost', user='foo', password='bar', 

the tests:

var expect = require('chai').expect; var db = require('../db/config.ini');  describe('database access', function() {     it('host parameter should string', function() {         expect(host).to.be.a('string');     });     it('user parameter should string', function() {         expect(user).to.be.a('string');     });     it('password parameter should string', function() {         expect(password).to.be.a('string');     });     it('db parameter should string', function() {         expect(db).to.be.a('string');     });     it('host parameter should equal localhost', function() {         expect(host).to.equal('localhost');     });     it('user parameter should equal foo', function() {         expect(user).to.equal('foo');     });     it('password parameter should equal bar', function() {         expect(password).to.equal('bar');     });     it('db parameter should equal thatone', function() {         expect(context).to.equal('thatone');     }); }); 

when add database choose,

db='thatone'; 

the test fails parameter because reads object.

  1) database access db parameter should string:      assertionerror: expected {} string       @ context.<anonymous> (test/db_tests.js:21:20) 

if change variable name "context" test passes expected.

i'm wondering if there obvious missing using "db" variable.

update stupid, novice level mistake. focused on learning testing methodology didn't realize had created 'db' var require 'ini' , referenced later though unique.

really dumb. rushing through recklessly destination, , failing follow methodology.

the result of executing not string:

var db = require('../db/config.ini'); 

it seems trying file in ini dialect meaningfully interpreted node. node not support default. if not error while loading it, reason text have in there happens valid javascript since ini files not contain proper code export (i.e. file not contain exports.db = "something" or module.exports = { ... } or similar), module has value {}.

you need add 1 of multiple npm packages automatically interpret ini file , provide meaningful value. cannot recommend 1 don't use ini files in software can search npm package perform translation you.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -