Skip to content

Using 'name' as variable name produces error #142

@newhouse

Description

@newhouse

Something like this:

describe('a test', function ()  {
  def('name', () => 'Some Name')

  it('works', function () {
    expect($.name).to.eql('Some Name')
  })
})

Results in an error like this:

Error: Cannot create lazy variable "name" as variable with the same name exists on the provided context
    at defineGetter (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:768:13)
    at Object.onDefineVariable (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:784:7)
    at runHook (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:471:22)
    at def (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:367:9)
    at Suite.<anonymous> (/Path/to/my/project/test/server/lib/filestore.test.js:2:3)
    at SuiteTracker.execute (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:553:19)
    at SuiteTracker.trackSuite (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:538:12)
    at Suite.defineSuite (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:529:19)
    at Object.create (/Path/to/my/project/node_modules/mocha/lib/interfaces/common.js:148:19)
    at Object.only (/Path/to/my/project/node_modules/mocha/lib/interfaces/common.js:106:21)
    at context.describe.only (/Path/to/my/project/node_modules/mocha/lib/interfaces/bdd.js:69:27)
    at Function.detectSuite [as only] (/Path/to/my/project/node_modules/bdd-lazy-var/getter.js:524:25)
    at Object.<anonymous> (/Path/to/my/project/test/server/lib/filestore.test.js:1:85)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Module._compile (/Path/to/my/project/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Object.newLoader [as .js] (/Path/to/my/project/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Module.require (internal/modules/cjs/loader.js:965:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.exports.requireOrImport (/Path/to/my/project/node_modules/mocha/lib/esm-utils.js:42:12)
    at Object.exports.loadFilesAsync (/Path/to/my/project/node_modules/mocha/lib/esm-utils.js:55:34)
    at singleRun (/Path/to/my/project/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at Object.exports.handler (/Path/to/my/project/node_modules/mocha/lib/cli/run.js:362:5)

I've not reproduced in a sterile environment, but I have grep'd my codebase and there is nowhere else that I def('name', ...)...and it would/should only matter if I do it in the same describe or context block anyways...

And in the spot where this is a problem, if I change the name from 'name' to anything else, it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions