Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start unit testing #14

Closed
wants to merge 1 commit into from
Closed

start unit testing #14

wants to merge 1 commit into from

Conversation

caub
Copy link

@caub caub commented Apr 21, 2018

Just a beginning for what I think could be useful as simple unit tests, it may be hacky

Don't hesitate to tell/close if you don't like this approach :)

and quick question: shouldn't this be case insensitive?

ps: I'm making this kind of thing also because I'm thinking about doing a minimal and lightweight dom implementation for svgo and use nwsapi on it

@caub caub force-pushed the test branch 2 times, most recently from 47bd9fa to e7a74b4 Compare April 21, 2018 10:17
@dperini
Copy link
Owner

dperini commented Apr 23, 2018

@caub sure ... anything related to testing is really important to follow improvements without having to manually recheck everything and to avoid regressions. Test automation is good.

Though I don't feel I have strong knowledge on current tools and practices.

As you can see there are a couple of test suites already available in the test folder and I am going to start adding WPT tests, only those related to selectors not the full suite.

@caub caub closed this Apr 23, 2018
@caub caub changed the title start unit testing (WIP) start unit testing Apr 23, 2018
@caub
Copy link
Author

caub commented Apr 23, 2018

@dperini I'm going to add WPT tests (similarly to jsdom)

When you've time, I'd like to figure out why https://github.com/caub/nwsapi/blob/test/test/unit.js#L173-L193 is not giving me what I'd expect

@dperini
Copy link
Owner

dperini commented Apr 24, 2018

@caub I looked into this and the only thing I can think of is that maybe the DOM you are building is missing some of the properties that "nwsapi" need to figure out things and/or auto configure.

They could be properties of document, like ".contentType" or properties of the elements themselves like ".localName", ".nodeName", ".namespaceURI" to be able to decide on the type of check to perform in the building of the function resolver.

No other ideas till now should I have other findings I will report them here.

@caub
Copy link
Author

caub commented May 17, 2018

Hmm I don't really know how to run WPT tests for nwsapi, would we have to make a script to insert <script src="path/to/nwsapi.js"></script> in each file in dom/nodes)?

For now it's quite good enough to test on jsdom no?

Btw, still trying to make https://github.com/caub/nwsapi/blob/test/test/unit.js work, like I told you it'd allow to integrate nwsapi in any parser, like a custom svg parser (particularly for svgo), besides also allowing easy tests.

@dperini
Copy link
Owner

dperini commented May 17, 2018

@caub
The current method I use to test "nwsapi" against WPT in browsers is by manually executing "test/w3c-test.sh" from a terminal.

That requires a recent version of PHP7 installed since that shell snippet executes the HTTP server embedded in the PHP7. At that point you can access the list of WPT tests by connecting to "localhost:8000" with the browser of choice.

The other tests can be run simply by loading the ".html" file in each folder.

From 'jsdom' you have to "npm run test" from inside the 'jsdom' root folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants