AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

Test in browser #519

Closed mathiasrw closed 8 years ago

mathiasrw commented 8 years ago

To avoid hidden browser specific issues (as #517) it would be good to be able to run all the tests from a .html file that can be opened in different browsers.

It could be inspired by something like https://nicolas.perriault.net/code/2013/testing-frontend-javascript-code-using-mocha-chai-and-sinon/ (I am sure there are many other options)

We need to be able to reuse the same test files as when testing node.

agershun commented 8 years ago

There is a special file: test/index.html which runs mocha tests in browsers. I did not updated for some time, but now it is more or less updated. Unfortunately, AlaSQL produces some errors into it, so it is a new set of challenges for us.

I usually run local server in /alasql directory:

    > cd alasql
    alasql> http-server

Then run this page from browser:

    http://localserver:8080/test

@mathiasrw Could you adjust test374 and test376, so they can work in browser?

agershun commented 8 years ago

We have 42 (!) failures in browser test. It is time to fix them (including IndexdDB problems)

mathiasrw commented 8 years ago

I got the following stats:

Firefox 42

Safari 9

Chrome 47

I might put test results into test and have testlog.md as somewhere to put final scores

mathiasrw commented 8 years ago

Could you adjust test374 and test376, so they can work in browser?

Only saw this now. Yes for sure!

agershun commented 8 years ago

I have changed browsers tests and fixed IndexedDB. @mathiasrw Could you pull the changes?

mathiasrw commented 8 years ago

Sure!

mathiasrw commented 8 years ago

Firefox 42

Safari 9

Chrome 47

agershun commented 8 years ago

Thnx! It is a good time to study debugger tools for Safary/FF/IE. BTW we need to check with IE also (I will run tests tomorrow)

mathiasrw commented 8 years ago

:+1:

agershun commented 8 years ago

There is a big difference how FF and Chrome treat new Date(value) expression.

FF is more sensitive to incoming date formats...

mathiasrw commented 8 years ago

When we build a modular system we could make it possible to include the date time magic from momentsjs

mathiasrw commented 8 years ago

Made a solution so we dont need to remember to add new tests to the browser test.

If we dont want a test to be included in the browser we can add if(window) return; inside describe(...

Please pull and run npm run test:browser

There is a - ehh - funny feature when you run it in safari - im working on it.

Last stats:

Chrome 47

Firefox 16

Safari 9

agershun commented 8 years ago

Please, use:

   if(typeof exports != 'object') {...}

instead of:

   if(window) {...}

Try to run mocha . in Node.js now :)

mathiasrw commented 8 years ago

:+1:

mathiasrw commented 8 years ago

Ran the full SQLlogictest - and last version make sure that 3 new test files are 100% ok - woohooo !!!

So now we have 135 out of 622 files 100% OK

agershun commented 8 years ago

:+1:

Now if you run mocha . it opens the browser with empty page. How to eliminate this?

mathiasrw commented 8 years ago

Hmm. That is strange.

I have changed no files that I did not create for the new setup.

I have to look into that.

mathiasrw commented 8 years ago

Can reproduce error any more.