-
Notifications
You must be signed in to change notification settings - Fork 308
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
NativeScript Support #994
Comments
Look quite similar to the current setup file we currently have https://github.com/thymikee/jest-preset-angular/blob/master/src/config/setup-jest.ts , small differences are the importing of nativescript files. |
When playing around with it I found this error.
Seems like we need commonjs nativescript modules to work under jest 🤔 |
that error is because Jest detects that the You can use transformIgnorePatterns to tell Jest to explicitly transform the files you need. It looks to me like Another way is using Jest in ESM mode. |
that one requires |
Looks like this did the trick for that one.
Although we may have found the limit of this as we are getting into missing globals.
|
|
I think that is intended to be bound to a native implementation via the NativeScript runtime, so not sure we can solve that in a node environment without polly filling it or something. In any case, it would be nice to configure that testing module maybe an interface like this. import { configurePreset } from 'jest-preset-angular';
import { NativeScriptTestingModule } from '@nativescript/angular/testing';
import '@nativescript/core/globals';
import '@nativescript/angular/polyfills';
import '@nativescript/zone-js/dist/pre-zone-polyfills';
configurePreset(NativeScriptTestingModule);
import '@nativescript/zone-js'; Not sure this would give the exact execution ordered needed given the import side effects. |
Regarding to global Node objects, you might need to do
something like that
I think for NativeScript, the current setup won't be reusable. It looks to me like NativeScript environment would require different set of imported files. I was thinking about having 2 separate setup files, one is the existing one, one is for NativeScript. So you would do in your local setup jest file
for example. Also there would be separate presets for NativeScript which can be created in https://github.com/thymikee/jest-preset-angular/tree/master/presets |
Having a separate entry point would be |
do you have an example repo of Ns + Angular with some example tests? |
I am still in preliminary investigation of the NativeScript platform myself, however their demo app does have some test built into it. https://github.com/NativeScript/angular/tree/main/apps/nativescript-demo-ng |
I looked a bit today about the NSObject. It seems like something in C or C++ which isn’t exposed by default as a global script setup. My guess is during the start up of the dev server, The main problem now when using Jest with jsdom is the potential global objects from C/C++ not available to import. I also checked a bit about Detox but it seems to work in a different way since it requires to build the app first before running tests. The positive point is the approach of Detox is also possibly the approach which we want to change also for the existing Angular Jest integration. Another thing I haven’t tried is: whether or not we can reuse what we are importing for existing Jest Angular integration instead of things from |
@ahnpnl you have a working example with NS and jest? |
Sorry we don’t have at the moment. I did a few attempts to set it up but wasn’t quite successful. |
🚀 Feature Proposal
Support NativeScriptTestingModule.
Motivation
NativeScript is maturing a lot, recently doing a complete overhaul of their Angular support.
Example
From what I can tell from their documentation the only major blocker here is the hard coded browser testing module.
If that could be injected to be arbitrary then every thing else can be handled in the project configuration.
The text was updated successfully, but these errors were encountered: