-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(runner): new integration with jest-circus #2009
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
Conversation
You are my hero |
@noomorph sorry for repeating myself, but really - do we really need to keep jasmine as 'legacy'? Can we not just deprecate in a major version and move on? |
@d4vidi, I really really want to rewrite adapter in a very breaking manner, so I would go an extra mile postponing a major release to not breakchange two times in a row, with jasmine and with adapters. P. S. Actually this time I plan to kill adapters. No adapters anymore. This will become a major version. P. P. S. The problem is that you will be very hesitant to review extra 500 lines of code in a single pull request, most likely, if I continue adding changes to here, so that's why I considered splitting into two PRs. |
f7a54e4
to
addd549
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
57a69c6
to
425bca6
Compare
This is so important, we should have done this kind of thing a long time ago, tapping in at the configuration space instead of the user space. |
That would also enable a fix for #2097, as the device's platform would already be known before
|
a1933bf
to
ad48933
Compare
With this new integration with jest-circus. How should I launch the app with the permissions I need? I got my tests working again by overriding the
Is this the best way to define permissions for my device? |
@wlindner, at the moment, not much time has passed since this feature entered production; hence I can't say for sure what the best method is. Alternative approachIn one of our projects, we apply another approach since the initialization phase is more complicated, e.g., starting a mock server and some CI preparations. detox.config.jsmodule.exports = {
// ...
behavior: {
init: { launchApp: false },
},
// ...
}; init.jsbeforeAll(async () => {
// launch mock server and other stuff
await device.launchApp({permissions: { /* ... */ }});
}); jest.config.jsmodule.exports = {
...
+ setupFilesAfterEnv: ["./init.js"],
...
}; Pros and consinitDetox()Pros. If you keep all your initialization steps in the protected Cons. Any potential timeout errors of beforeAllPros. The Cons. Most likely, if you have ConclusionTry out If you nevertheless prefer overriding the |
New projects by default will be using a new test runner integration between Detox and
jest-circus
.Motivation
Initiate Detox as early as possible, even before we know what tests we are going to run. That potentially enables discarding
--testNameRegexPattern=(^(^()^())
workaround for Jest, as in this position we will be able to decide in runtime which tests we want to skip, and which - not. Also, the initialization errors won't be bound to some specific test - less clutter and misleading information for users.Compared to previous
jest-circus
integration, we remove that a bit alienglobal.detoxCircus
environment variable. Now, registering the listeners happens right in a user-defined environment class which derives fromDetoxCircusEnvironment
. On the other hand, we add a globaldetox
variable, because of the very same sandboxing issues (to avoid creating many isolated Detox instances with every nextrequire('detox')
- seedetox/src/index.js
for the actual place).Together with removing
detoxCircus
variable, and moving concerns into environment class, at the end of the day, we gain freedom from./init.js
environment setup files. We don't depend on user-defined hooks (beforeAll
,beforeEach
,afterEach
,afterAll
) - now we run above that. That's why the new DetoxCircusEnvironmnent has less complexity because it does not mediate between things happening in user-facing code (setupFilesAfterEnv: ['init.js']
) and jest-circus'handleTestEvent
events.We used to run
afterEach
lifecycle actions as a first thing in the consequent test'sbeforeEach
(ordetox.cleanup()
if there were no next tests). That led sometimes to issues when failures indetox.afterEach()
(hence, incomplete execution of all planned routines) of the previous test could impact the behavior ofdetox.beforeEach()
of the current one.It resolves Take screenshot after test failure, before afterEach is executed #1661 - artifacts plugins become able to react ASAP to specific failure inside tests, before any hook (e.g.
afterEach
) executes. That should improve the relevance of post-error screenshots, as one of the consequences.Description
Instead of a well-known
e2e/init.js
file, you are going to havee2e/environment.js
file.The entire class is optional if you don't plan to use the customizations above.
Jest's
e2e/config.json
has the following changes:Miscallenous
CI scripts are targeting
jest-circus
by default.jest-jasmine
is tested only for the edge case withdetox.init()
timeout.