haroldiedema / joii

Javascript Object Inheritance Implementation
MIT License
70 stars 13 forks source link

Fixed unit testing in browser #27

Closed cjmanca closed 7 years ago

cjmanca commented 7 years ago

Now tests properly in browser (with src version), and via npm test (with dist version)

haroldiedema commented 7 years ago

Doesn't work in a browser for me.

GET file:///D:/joii/node_modules/qunit/node_modules/qunitjs/qunit/qunit.js net::ERR_FILE_NOT_FOUND
testsuite.html:5 GET file:///D:/joii/node_modules/qunit/node_modules/qunitjs/qunit/qunit.css net::ERR_FILE_NOT_FOUND
DeepCopyTest.js:16 Uncaught ReferenceError: test is not defined(…)(anonymous function) @ DeepCopyTest.js:16
InheritanceTest.js:31 Uncaught ReferenceError: test is not defined(…)(anonymous function) @ InheritanceTest.js:31
PropertyMetaTest.js:10 Uncaught ReferenceError: test is not defined(…)(anonymous function) @ PropertyMetaTest.js:10
TraitTest.js:10 Uncaught ReferenceError: test is not defined(…)

By the looks of it, you're installing a different version of qunit? Is your npm up-to-date?

haroldiedema commented 7 years ago

If you manage to get this working with a different qunit version, please add the version constraint to package.json and commit that as well.

The tests must work when you do a fresh clone of the repository. Right now, the browser tests don't work.

cjmanca commented 7 years ago

Hmm... I just deleted my node_modules directory, and ran "npm install", and all the tests (both npm test and browser tests) work perfectly with these changes...

Could you perhaps try doing the same to make sure there isn't an issue with your node_modules? That error you reported is the exact error (except with a different path) that I was getting with your original testsuite.js, which is part of the reason for all my tinkering with the testsuite. The unit tests didn't work "out of box", so to speak ;)

haroldiedema commented 7 years ago

I did exactly that.

Both on Windows 10 (my desktop pc) and Ubuntu (my vps).

I cloned your fork "as-is" and ran "npm install", followed by "npm test". This works so far. However, when opening testsuite.html in a browser, after running "npm test", it complains about files not being found, etc.

Since you're using Visual Studio, I assume you also run on Windows.

My VPS still had the old 0.10.x version of Node installed. I've tried it on that as well, but it produces the exact same errors. After upgrading it to the latest version, it's still the same.

Edit: I just tried to clone your fork on my workstation in the office (which runs Ubuntu). "npm install" and "npm test" work as expected. Opening the browser version fails with the exact same errors.

I think we can conclude that this isn't an OS issue. Also, the version of qunit that I put in package.json doesn't follow the directory structure that you're using anymore, hence I changed it.

cjmanca commented 7 years ago

I'm really at a loss now. I just followed those exact same steps you said you did, and again it worked... I just don't understand what's going on.

haroldiedema commented 7 years ago

Are you opening testsuite.html from a webserver (http://localhost/) or just running the file itself directly from file exlorer?

cjmanca commented 7 years ago

Locally from the file it's self, but I figured it out.

I had NPM version 2.x installed, and it would install all module dependencies in that module's subfolder. In NPM 3.x, they changed it to install the dependencies along side them in the main node_modules folder. Hence the path differences.

I updated my NPM to 3.x, and fixed the issue/committed an update.

haroldiedema commented 7 years ago

Aaahh, there we go! :smile: