-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
testing with the library "gl" (aka headless-gl) breaks if you have more than one test file #2029
Comments
Confirmed, this is really strange. Maybe |
Although it's most probably not Jest-related (but not 100% sure, maybe we run on some edge case here). So for now I'll close the issue but happy to keep the discussion going and reopen if necessary. |
Does it work with two files when doing |
Tested with |
That's really odd then because that makes it run in process, serially. It may indeed be a gl issue in this case. |
Not sure this will have any impact, but maybe try destroying the gl context at the end of each test (plus the
|
I'm pretty sure my tests aren't leaking a gl context (I mean, at least in my "real" tests, not the one I showcase. but yeah, I can try to add that, i'm pretty sure it won't change) |
I've updated the showcase with the even tho the tests are identically, only one pass. and a test file that contains twice the test still pass. this does not make sense. |
Yeah, I worked on it all morning... It is bizarre... I can't run the test a second time within the same Jest process instance. If I quit the jest process and start again its ok. As you mentioned, destroying contexts doesn't help, you can actually create many, many contexts in a loop without issue. At the moment it's working because I changed the function that tests for the type error. It's situated in
All I have done is loosen the void check from More work to do tomorrow. |
@mcrawshaw I made that change and my yarn tests were able to run successfully multiple times. We're not doing anything more than creating the GL context in our tests, but they were able to run multiple times. |
@thymikee given the above efforts, shall we reopen this? |
Let's keep this open until we find proper solution or fix the |
Closing due to: #3552 (as a workaround use |
interesting! thanks |
Hey, @mikolalysenko @mourner |
@alvinsight I'm not sure about that check, but I'd welcome a PR! |
I'm not sure on the fix I mentioned above, it was something I came too after tracing the code. When I apply the fix and run it now I receive this error: @gre your repo works when I think we need to understand just what is going on with the |
Ah, dang, good luck @mcrawshaw ! |
I found the reason, but I don't know how to fix it. I'm not sure this is the bug of gl or jest. In gl/webgl.js, there is such a piece of code: var gl = nativeGL.WebGLRenderingContext.prototype
// ...
var _framebufferTexture2D = gl.framebufferTexture2D // native function
gl.framebufferTexture2D = function framebufferTexture2D(
target,
attachment,
textarget,
texture,
level ) {
// ...
if ( !checkObject( texture ) ) {
throw new TypeError( 'framebufferTexture2D(GLenum, GLenum, GLenum, WebGLTexture, GLint)' )
}
// ...
} In another place in gl/webgl.js, there is such a piece of code: // line
for ( var i = 0; i < ATTACHMENTS.length; ++i ) {
_framebufferTexture2D.call(
context,
gl.FRAMEBUFFER,
ATTACHMENTS[ i ],
gl.TEXTURE_2D,
0, // -> as parameter `texture`
0 )
} under normal circumstances, checkObject( texture ) -> checkObject( 0 ); function checkObjectA (object) {
return typeof object === 'object' ||
!object
}
function checkObjectB (object) {
return typeof object === 'object' ||
(object === void 0)
}
checkObjectA( 0 ); // true
checkObjectB( 0 ); // false |
I believe I know what the issue is, it is that how the library is being instantiated. There are a lot of jit overriding happening and privatizing of the native methods. The refactor I'm working on here: stackgl/headless-gl#166 should resolve it as it no longer overwrites the methods, but just properly calls them using |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What is the current behavior?
I have written 2 identical tests.
Repository that reproduce the bug:
https://github.com/gre/jest-multi-tests-gl-issue
What is the expected behavior?
The tests should pass. (it passes in a same file!)
--debug
The text was updated successfully, but these errors were encountered: