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)
- Ensure all doc drivers return documents of correct formats
- Cancel attachment transfers when syncing is cancelled
- Unclear how to use "earthstar identities switch" HOT 3
- Add a way to reject ingesting documents from certain users during sync
- Add a way to specify an attachment size limit during sync
- Add forgetting methods to replica HOT 1
- Persist document syncing thumbnails
- Use Web Locks API for ingestion
- Server <> Server syncing
- [FR] File size limit > 4 mb HOT 2
- Direct p2p online sync with WebRTC HOT 1
- Attachment sync not working on Deno runtime HOT 1
- Restricting the paths an applet can read and write to HOT 2
- What is this key for in `syncReplicaAndFsDir` ? HOT 1
- ReplicaDriverWeb not accessible from all environments HOT 4
- 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 2
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.