Comments (2)
I did a little bit of looking into this as earthstar-graphql also needs tests that run in a node-like environment and a browser-like one. In that repo I'm using jest, which lets you configure the environment used for testing: you can use jsdom
to test how code would run in a browser. I'm going to try configuring it so that the same test suites run in both environments.
But that's not very useful here, is it? 😅 It seems like tap is made specifically for testing in node environments? I couldn't find docs about configuring it otherwise.
I will see how this shakes out in earthstar-graphql, and if there is ever any appetite to migrate tests to jest in this repo, I'm more than happy to help.
from earthstar.
Yeah, turns out tap
only works in node. But tape
is almost identical and it can be browserified! So I kinda got this working but it's awkward.
(jsdom
doesn't help here since it just emulates browser APIs and we need to test the actual browser javascript engine.)
Commit: 8a2bd98
Docs are in karma.conf.js
, also pasted below.
Unfortunately this didn't detect #48 "detChoice problems in browser", it just worked. :/ In headless chrome, anyway.
How this works
Run npm run test-in-browser
to do all these steps at once:
- npm run clean
- npm run build // typescript build
- npm run browserify-for-karma // make a bundle from one test file
- npm run karma // run karma headless browser test on the bundle
The browserify step currently can only process one of the *.test.js files.
It's hardcoded in package.json in the "browserify-for-karma" step.
Change it there to run different tests.
To fix this, I think browserify would need to make a separate bundle
for each of our *.test.js files.
ALSO
The tap
module is not browserifiable. We tell browserify to
swap it for tape
(see the browser
section of package.json).
tape's API is almost identical except it doesn't have t.done(), it has t.end().
So write all the tests using t.end(), which works in both.
FUTURE IMPROVEMENTS
The npm packages karma-browserify
and karma-typescript
look promising
but I was not able to get them working.
from earthstar.
Related Issues (20)
- Upgrade SQLite3 dependency to 0.8.0
- Address private set intersection exploit HOT 2
- What is the rationale for the generateAuthorKeypair shortname only allowing lengths of 4 chars? HOT 1
- npm install error HOT 1
- Adding denoKV to doc drivers HOT 4
- ReplicaCache#onCacheUpdated not triggered until you call cache.queryDocs()? HOT 3
- Error compiling typescript file that imports earthstar npm package
- ExtensionKnownShares loading known shares from memory HOT 1
- Export a browser entrypoint with IndexedDB StorageDriver
- Port Discovery API + DiscoveryLan
- Add way to check if Auth has been set up yet
- Add way to check if given password is correct on Auth
- Auth should be an EventTarget and emit events
- Peer should be an EventTarget and emit events
- IdentityKeypair + ShareKeypair secretKey property should be Base32 encoded string
- "All-in-one" authorisation
- Lots of duplicate auth stuff in the store HOT 5
- Filter sparse documents from store results unless specifically requested
- Cinn25519 shortname encoding is incorrect
- TypeError: The input must be a Uint8Array, a string, or an ArrayBuffer. Received a value of the type undefined. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from earthstar.