erikringsmuth / app-router

Router for Web Components
https://erikringsmuth.github.io/app-router/
MIT License
611 stars 83 forks source link

run test from gulp #13

Closed erikringsmuth closed 9 years ago

erikringsmuth commented 10 years ago

Currently you have to run tests from the browser. https://github.com/erikringsmuth/app-router#build-test-and-debug-

Tests can't be run in Node.js test runners (Jasmine, Mocha) or PhantomJS test runners because none of them support custom elements.

The problem can be partially mitigated by moving "utility" functions to a different file. These are the functions that don't rely on DOM APIs.

parseUrlPath(url) https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L183

testRoute(routePath, urlPath, trailingSlashOption, isRegExp) https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L214

routeArguments(routePath, urlPath, url, isRegExp) https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L214

I don't want create globals so loading a <script src="..."> is out of the question. I'd like to move to ES6 modules and add a transpile step to gulp. This would allow some code to be tested with Jasmine or Mocha and run from gulp.

petabyte commented 9 years ago

I can setup gulp-karma to run jasmine

https://www.npmjs.org/package/gulp-karma

The karma-config can choose a browser to test again

erikringsmuth commented 9 years ago

That'd be awesome!