-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
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. |
testem.js
Outdated
@@ -0,0 +1,66 @@ | |||
/* eslint-disable import/no-commonjs */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
.circleci/config.yml
Outdated
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sudo
? Docker builds typically run as the root user anyway.
…est-browserify # Conflicts: # .circleci/config.yml # yarn.lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nearly ready. A few items to wrap up before merging:
- Update
test-query
and relatedpackage.json
scripts 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.
.circleci/config.yml
Outdated
@@ -100,7 +100,7 @@ jobs: | |||
- restore_cache: | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…est-browserify # Conflicts: # package.json # yarn.lock
…est-browserify # Conflicts: # yarn.lock
This PR adds a bunch of new tooling to allow the
query
tests to be run in the browser.New tools added:
testem
: this is a test-runner that that handlesxunit
formattape
: 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.json
file withintest/integration/dist
that contains all the data within the directory inlined within it, this file can then be imported into the test root file and therollup
will 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 viarollup
as an iife so that tests start executing as soon as the script is loaded.3. Test running
testem
provides hooks to run custom code before and after tests. Thebefore_tests
hook 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).testem
then 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 thetap
formattedconsole.log
messages and relays them over websocket to be interpreted on the server to detect when the test suite has finished.It then converts the gathered
tap
formatted report and convertes it toxunit
format 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-browser
runs all the tests in headless chrome and exitsyarn run watch-query
starts build watchers and launches a chrome window to run tests so you can work iterate on tests.yarn run start-query-debug
starts both the test server and the debug server while sharing the saem build-watcher.