Comments (13)
i'll try to find some time this week to have a look!
from tape.
It's a bit tough to reproduce from here without the content of the scripts.
from tape.
Generally though, I'd expect browser tests to be always bundled into a single file, not directly loaded with a script tag?
from tape.
Here is my setup:
karma.conf.js:
from tape.
Generally though, I'd expect browser tests to be always bundled into a single file, not directly loaded with a script tag?
I can't bundle all my test files into a single file, I'm using karma
. I can't concatenate files into one (I considered karma-concat-preprocessor because of duplicated import
statements (and that probably won't work well with sourcemap).
I tried to do import test from 'tape[-catch]'; test.wait();
and run the tests manually at the end via test.run()
. Problem is that tests were not registered to the stream (.on('_push')
in results.js was not called each time a test is added)
The only way I found to prevent the tests from running (i.e. setTimeout()
from being called), is to replace setTimeout()
with a custom window.setImmediate
do before any test <script>
:
let testRunner;
window.setImmediate = (runTest) => {
testRunner = runTest;
};
And catch when karma is started as such:
function createStartFn(tc) {
return function() {
if (testRunner) {
testRunner();
} else {
console.log('no test runner !');
}
};
}
window.__karma__.start = createStartFn(window.__karma__);
This is definitely not pretty, but that works. If you can find a better to do it, I take it :-)
from tape.
I'm not clear on why using karma precludes bundling; i've set up karma with a bundle before.
I'm not familiar with tape-catch - but it seems like it's possible that it was last updated when tape was in v3, and thus breaking changes in v4 and v5 may have caused it not to work properly anymore. It's ofc also possible that tape-catch is working fine :-)
I'm happy to try to change something in tape if that would help your use case, I'm just not clear on what that would be :-/
from tape.
I'm not clear on why using karma precludes bundling; i've set up karma with a bundle before.
Maybe it's doable, I just couldn't figure out. But I think it is "better" to have tape support being ran when tests are not bundled.
I'm not familiar with tape-catch - but it seems like it's possible that it was last updated when tape was in v3, and thus breaking changes in v4 and v5 may have caused it not to work properly anymore. It's ofc also possible that tape-catch is working fine :-)
I've the same problem without tape catch.
I'm happy to try to change something in tape if that would help your use case, I'm just not clear on what that would be :-/
The problem is that the setTimeout()
next
callback (in results.js) is called too early. The fix would be to give tape
users the control on when the next
function is being called. In a way, if you could 1) expose an option in createStream()
that prevents setTimeout()
from being called, 2) expose a function to manually call the next
function, that would be great.
from tape.
Or more simply, there is a wait()
function in tape. It would be sufficient if there is a resume()
function as well.
from tape.
Isn't that .run()
?
from tape.
Isn't that
.run()
?
I wish but it does not work. Here is what's going on:
test.wait();
test.createStream({objectMode:true}); // will not call Results.createStream() because of `.wait()`
...
test('Test1', (t) => {...}); // does not call `self.on("_push", ontest(...)` because `Results.createStream()` has not yet been called
...
test.run(); // will call `Results.createStream()` and will execute the tests but their events (e.g. "data") are not caught/forwarded to the stream.
from tape.
Hm, that seems like a bug with the βwaitβ functionality (cc @lohfu)
from tape.
@lohfu have you had a chance to have a look ?
from tape.
@finetjul hi, sorry for the delay. unfortunately i'm an incredibly unreliable individual often falling into deep holes of darkness where i forget about the world around me and any commitments i have there.
i've had a quick look at your problem now, and while it's near impossible without substantial work to reproduce your issue from the screenshots you have provided i think solving it could require even more quirky workarounds than my .wait()
and .run()
functions without exposing more of the internals of harness creations than today. It was a a year or two ago since i worked on the esm conversion, but i recall wanting to expose createExitHarness
instead of just createHarness
. I cant remember exactly why I wanted to do this, but I struggle a little to see how the examples from your screenshots triggers the .wait()
logic from the bin/tape
executable.
I find it slightly odd you provide screenshots of code instead of actual pasted code. I would like to try to reproduce your issue locally, do you think there is any chance to you could provide a simple repo or gist of a similar setup to help me see what's going on?
from tape.
Related Issues (20)
- Automatically exclude node-specific packages from browser bundlers HOT 6
- How do I mock an image import? HOT 5
- Are you able to publish a new version of tape? HOT 6
- Feature Request: --no-only flag for tape CLI command HOT 9
- t.comment adds multiple new lines for multi-line strings HOT 9
- Enhancement request: ESM version for testing apps that use custom ES Module Loaders HOT 2
- RFE: Document use with TypeScript HOT 4
- Cannot create a stream then load ESM test modules HOT 9
- Using typescript with esm leads to importOrRequire issue HOT 5
- Looking for a tap reporter HOT 4
- CLI accept multiple directories and execute in order HOT 2
- How do I run single test? HOT 1
- CLI options for IDE integrations. HOT 5
- tests seem to fail on windows. HOT 6
- Suggestion: Ignore pattern directly instead of pointing to a file? HOT 3
- Upgrade to TAP 14 - support for subtests, maybe indentation? HOT 1
- Tips on how to run a single test HOT 2
- t.true() should be exact. HOT 8
- Async: supported or not? Change docs? 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 tape.