Running query tests in browser - #8584
Conversation
…est-browserify # Conflicts: # yarn.lock
…est-browserify # Conflicts: # package.json # yarn.lock
…est-browserify # Conflicts: # test/integration/lib/server.js
Unfortunately testem does not play nice with
I added the watchers you can now do. |
| @@ -0,0 +1,66 @@ | |||
| /* eslint-disable import/no-commonjs */ | |||
There was a problem hiding this comment.
Does this file need to be in the root directory? If not, let's move it to somewhere in the /test/* directory hierarchy to avoid clutter.
| - v2-yarn-{{ checksum "yarn.lock" }} | ||
| - run: yarn | ||
| - v3-yarn-{{ checksum "yarn.lock" }} | ||
| - run: sudo npm install -g yarn & yarn install |
There was a problem hiding this comment.
Why sudo? Docker builds typically run as the root user anyway.
…est-browserify # Conflicts: # .circleci/config.yml # yarn.lock
asheemmamoowala
left a comment
There was a problem hiding this comment.
This looks nearly ready. A few items to wrap up before merging:
- Update
test-queryand relatedpackage.jsonscripts to use this version of the test instead of the node based tests - Update integration tests readme with instructions to run the node-based tests, and to run/debug the testem based tests.
| keys: | ||
| - v3-yarn-{{ checksum "yarn.lock" }} | ||
| - run: sudo npm install -g yarn & yarn install | ||
| - run: npm install -g yarn & yarn install |
There was a problem hiding this comment.
needs a && to serialize the steps. A Single & will fork and try to run it in the background
- update debug pages to have a more reliable part to `access_token_generated.js` - Update npm run scripts for query tests to use browser version by default.
Done 👍 , I also made it so that it starts the testem server when running |
… process to prevent terminal from getting messed up.
…est-browserify # Conflicts: # package.json # yarn.lock
…est-browserify # Conflicts: # yarn.lock
This PR adds a bunch of new tooling to allow the
querytests to be run in the browser.New tools added:
testem: this is a test-runner that that handlesxunitformattape: browser compatible version oftap, used to write the tests.browserify: tape is not browser compatible ootb, so we need to build it ourselves, and rollup does not handle tape's commonjs style well and fails at trying to inject node globals and builtins. So we build it with browserify.Architecture:
1.Loading fixture data to the browser
This is done via a preprocessor that generates
fixtures.jsonfile withintest/integration/distthat contains all the data within the directory inlined within it, this file can then be imported into the test root file and therollupwill inline everything so all the data is available synchronously.2.Bundling resources for the browser
There are 3 bundles that get built in parallel before the test suite starts
-
tape_config.js: Done via browserify, and exposed as a globaltape.mapboxgl: Done viarollup, exposed as a globalmapboxgl.query-browser.js: this is the entrypoint of the test suite, built viarollupas an iife so that tests start executing as soon as the script is loaded.3. Test running
testemprovides hooks to run custom code before and after tests. Thebefore_testshook is used to run the build, and start an http server thats used to serve up certain resources such as spritesheets and fonts( this is the same as the existing implementation).testemthen launches its own server with a static html page which server up the built javascript resources. An extra script injected by testem onto the page captures thetapformattedconsole.logmessages and relays them over websocket to be interpreted on the server to detect when the test suite has finished.It then converts the gathered
tapformatted report and convertes it toxunitformat for integration with CircleCI's test reporting.4.Test reporting
testem finishes running tests and persists the test report in xunit format to disk.
I've intentionally left a failing query test so we can see how it shows up in circle.
Guide:
Adds a bunch of npm scripts:
yarn run test-query-browserruns all the tests in headless chrome and exitsyarn run watch-querystarts build watchers and launches a chrome window to run tests so you can work iterate on tests.yarn run start-query-debugstarts both the test server and the debug server while sharing the saem build-watcher.