sealcode / sealious

An extensible, declarative node framework
25 stars 2 forks source link

`AccessStrategyType` is not a constructor #281

Closed adwydman closed 8 years ago

adwydman commented 8 years ago

I am unable to test modules that use new AccessStrategyType, because I get this error all the time. Example stack:

C:\Users\anwi\Desktop\sealious\lib\chip-types\access-strategy.js:9
                this.type = new AccessStrategyType(declaration);
                            ^

TypeError: AccessStrategyType is not a constructor
    at AccessStrategy (C:\Users\anwi\Desktop\sealious\lib\chip-types\access-strategy.js:9:15)
    at ResourceType (C:\Users\anwi\Desktop\sealious\lib\chip-types\resource-type.js:25:12)
    at Suite.<anonymous> (C:\Users\anwi\Desktop\sealious\tests\unit-tests\single-resource-subject.test.js:19:14)
    at context.describe.context.context (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\interfaces\bdd.js:47:10)
    at Suite.<anonymous> (C:\Users\anwi\Desktop\sealious\tests\unit-tests\single-resource-subject.test.js:14:2)
    at context.describe.context.context (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\interfaces\bdd.js:47:10)
    at Object.<anonymous> (C:\Users\anwi\Desktop\sealious\tests\unit-tests\single-resource-subject.test.js:13:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\mocha.js:220:27
    at Array.forEach (native)
    at Mocha.loadFiles (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\mocha.js:217:14)
    at Mocha.run (C:\Users\anwi\Desktop\sealious\node_modules\mocha\lib\mocha.js:469:10)
    at Object.<anonymous> (C:\Users\anwi\Desktop\sealious\node_modules\mocha\bin\_mocha:404:18)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (node.js:348:7)
    at startup (node.js:140:9)
    at node.js:463:3

Is there any reason behind this?

kuba-orlik commented 8 years ago

There must be a reason! But the reason might be an accident ;p

Please log the value of AccessStrategyType just before calling new AccessStrategyType :)

adwydman commented 8 years ago

There must be a reason! But the reason might be an accident ;p

"There must be a reason!" sounds like a cool slogan of a religious group. :D

Please log the value of AccessStrategyType just before calling new AccessStrategyType :)

It's prints an empty object {}, which is strange, because the file is exporting a whole function.

kuba-orlik commented 8 years ago

Hmmm, it seems like a problem with circular dependencies. What node version are you using? Have you tried running the test on a different version?

adwydman commented 8 years ago

Can Node version affect the way code is executed so that it's broken on one version and working on the other?

kuba-orlik commented 8 years ago

Yes, I had that exact problem - there's a been a change somewhere around version 5 to how Node handles circular dependencies, and I saw Sealious fail on newer version, while working fine on the older version. I cannot put my finger on how exactly did the behavior change - so I'll give a kingdom for a simple test-case demonstrating that!

Please try changing your Node version.

adwydman commented 8 years ago

Noted.

adwydman commented 8 years ago

It doesn't work either way.

kuba-orlik commented 8 years ago

Which commit are you on? Could you try it on 829cb67c1b1b48f4f1b5?

adwydman commented 8 years ago

This is what I get when I run tests:

$ npm test

> sealious@0.7.11 test C:\Users\anwi\Desktop\sealious
> node ./tests/test.js

C:\Users\anwi\Desktop\sealious\lib\subject\subject-types\resource-type-field-subject.js:14
ResourceFieldTypeSubject.prototype = Object.create(Sealious.Subject.prototype);
                                                                   ^

TypeError: Cannot read property 'prototype' of undefined
    at Object.<anonymous> (C:\Users\anwi\Desktop\sealious\lib\subject\subject-types\resource-type-field-subject.js:14:68)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\anwi\Desktop\sealious\lib\subject\subject-types\single-resource-subject.js:4:32)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
npm ERR! Test failed.  See above for more details.
kuba-orlik commented 8 years ago

ResourceFieldTypeSubject.prototype = Object.create(Sealious.Subject.prototype);

This line is no longer present on the references branch. Please pull the latest changes. If you're on a different branch, merge references into it :)

adwydman commented 8 years ago

I checked out on 829cb67 as you asked and this is what I got when running tests.

kuba-orlik commented 8 years ago

I see, then - the problem should go away if you try the latest references branch. If that's the case, please close this issue :)

adwydman commented 8 years ago

Yes, tests work on references.