Skip to content
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

NSUTR: New jasmine install fails #5690

Closed
3 tasks done
AdamAtri opened this issue Sep 6, 2022 · 3 comments · Fixed by #5695
Closed
3 tasks done

NSUTR: New jasmine install fails #5690

AdamAtri opened this issue Sep 6, 2022 · 3 comments · Fixed by #5695

Comments

@AdamAtri
Copy link

AdamAtri commented Sep 6, 2022

Issue Description

Running unit tests on a newly created project fails when selecting "Jasmine" as the test runner:

You can now run your tests:

  $ ns test ios
  $ ns test android

adamatri:~/Project/testp$ ns test android --emulator
Searching for devices...
06 09 2022 14:26:50.293:WARN [karma-server]: Passing raw CLI options to `new Server(config, done)` is deprecated. Use `parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` to prepare a processed `Config` instance and pass that as the `config` argument instead.
06 09 2022 14:26:50.512:WARN [karma]: No captured browser, open http://127.0.0.1:9876/
06 09 2022 14:26:51.090:INFO [karma-server]: Karma v6.4.0 server started at http://127.0.0.1:9876/
06 09 2022 14:26:51.090:INFO [launcher]: Launching browsers android with concurrency unlimited
06 09 2022 14:26:51.093:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Copying template files...
Platform android successfully added. v8.3.1
Preparing project...
webpack is watching the files...
resolving "./stop-process.js" to "./stop-process.android.js"
asset vendor.js 6.5 MiB [emitted] (name: vendor) (id hint: defaultVendor)
asset bundle.js 18.1 KiB [emitted] (name: bundle)
asset runtime.js 11.5 KiB [emitted] (name: runtime)
Entrypoint bundle 6.53 MiB = runtime.js 11.5 KiB vendor.js 6.5 MiB bundle.js 18.1 KiB
runtime modules 2.46 KiB 7 modules
orphan modules 356 bytes [orphan] 6 modules
modules by path ./node_modules/@nativescript/ 1.53 MiB 208 modules
modules by path ./node_modules/css-tree/ 317 KiB 113 modules
modules by path ./node_modules/source-map/lib/*.js 36.3 KiB 6 modules
modules by path ./node_modules/reduce-css-calc/dist/ 131 KiB 5 modules
modules by path ./node_modules/postcss-value-parser/lib/*.js 12.5 KiB 5 modules
modules by path ./app/ 556 bytes
  ./app/test.ts 206 bytes [built] [code generated]
  + 2 modules
modules by path ./node_modules/mdn-data/css/*.json 242 KiB
  ./node_modules/mdn-data/css/at-rules.json 11.6 KiB [built] [code generated]
  + 2 modules
+ 4 modules
webpack 5.74.0 compiled successfully in 4133 ms
Webpack compilation complete. Watching for file changes.
Type-checking in progress...
File change detected. Starting incremental webpack compilation...
assets by status 6.53 MiB [cached] 3 assets
Entrypoint bundle 6.53 MiB = runtime.js 11.5 KiB vendor.js 6.5 MiB bundle.js 18.1 KiB
cached modules 2.47 MiB (javascript) 2.46 KiB (runtime) [cached] 359 modules
./app/ sync \.spec\.ts$ 188 bytes [built]
webpack 5.74.0 compiled successfully in 225 ms
Webpack compilation complete. Watching for file changes.
Type-checking in progress...
No errors found.
         ~ applying user-defined configuration from /Users/adamatri/Project/testp/App_Resources/Android/before-plugins.gradle
Built aar for @nativescript/core
Updating runtime package.json with configuration values...
Project successfully prepared (android)
Building project...
Gradle build...
         + applying user-defined configuration from /Users/adamatri/Project/testp/App_Resources/Android/before-plugins.gradle
         + applying user-defined configuration from /Users/adamatri/Project/testp/App_Resources/Android/before-plugins.gradle
         + setting applicationId
         + applying user-defined configuration from /Users/adamatri/Project/testp/App_Resources/Android/app.gradle
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/adamatri/Project/testp/node_modules/@nativescript/core/platforms/android/core.aar
         + adding aar plugin dependency: /Users/adamatri/Project/testp/node_modules/@nativescript/core/platforms/android/widgets-release.aar
         + adding aar plugin dependency: /Users/adamatri/Project/testp/node_modules/@nativescript/unit-test-runner/platforms/android/unit_test_runner.aar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Project successfully built.
Build time: 41.917 s.
The build result is located at: /Users/adamatri/Project/testp/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Installing on device emulator-5554...
Successfully installed on device with identifier 'emulator-5554'.
Restarting application on device emulator-5554...
Successfully synced application org.nativescript.testp on device emulator-5554.
  JS: NSUTR: fetching http://127.0.0.1:9876/context.json
  JS: NSUTR: fetching http://192.168.0.203:9876/context.json
  JS: NSUTR: fetching http://169.254.20.130:9876/context.json
  JS: NSUTR: fetching http://169.254.196.86:9876/context.json
  JS: NSUTR: fetching http://10.5.0.2:9876/context.json
  JS: NSUTR: fetching http://10.0.2.2:9876/context.json
  JS: NSUTR: error fetching http://127.0.0.1:9876/context.json Error: java.net.ConnectException: Failed to connect to /1
  27.0.0.1:9876
  JS: NSUTR: found karma at 192.168.0.203
  JS: NSUTR: connecting to karma at http://192.168.0.203:9876
  JS: NSUTR: found karma at 10.0.2.2
  JS: NSUTR: found karma at 169.254.20.130
  JS: NSUTR: successfully connected to karma
06 09 2022 14:27:50.647:INFO [NativeScript / 33 (13; sdk_gphone64_arm64)]: Connected on socket QOrncU0GF6BbLMRDAAAB with id NativeScriptUnit-6505
  JS: NSUTR: downloading http://192.168.0.203:9876/context.json
  JS: NSUTR: eval script /absolute/Users/adamatri/Project/testp/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?82
  bf6cfb195b9d0c4c25fbbafc07176191bc7d93
  JS: NSUTR: eval script /absolute/Users/adamatri/Project/testp/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1
  f8b252c1636d76201cc4e88
  JS: NSUTR: eval script /absolute/Users/adamatri/Project/testp/node_modules/karma-jasmine/lib/adapter.js?db55991565c0f0
  381ab0fb3c340df5194b4bef99
  JS: NSUTR: this.error: TypeError: global.addEventListener is not a function
  JS: at /absolute/Users/adamatri/Project/testp/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1f8b252c1636d7620
  1cc4e88
  JS: NSUTR: completed test run.
  JS: NSUTR: this.error: describe is not defined
  JS: NSUTR: completed test run.
06 09 2022 14:27:50.945:WARN [NativeScript / 33 (13; sdk_gphone64_arm64)]: Adapter did not report total number of specs.
NativeScript / 33 (13; sdk_gphone64_arm64)  /absolute/Users/adamatri/Project/testp/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1f8b252c1636d76201cc4e88 at line 0 FAILED
	TypeError: global.addEventListener is not a function
NativeScript / 33 (13; sdk_gphone64_arm64): Executed 1 of null (1 FAILED) (0.018 secs / 0 secs)
TOTAL: 1 FAILED, 0 SUCCESS
  JS: NSUTR: completeAck
  JS: NSUTR-socket.io: io client disconnect
  JS: NSUTR: completeAck
06 09 2022 14:27:51.951:WARN [NativeScript / 33 (13; sdk_gphone64_arm64)]: Disconnected (0 times) Client disconnected frNativeScript / 33 (13; sdk_gphone64_arm64) ERROR
  Disconnected Client disconnected from CONNECTED state (client namespace disconnect)
NativeScript / 33 (13; sdk_gphone64_arm64): Executed 1 of null (1 FAILED) (0.018 secs / 0 secs)
06 09 2022 14:28:20.967:WARN [NativeScript / 33 (13; sdk_gphone64_arm64)]: Disconnected (1 times) , because no message iNativeScript / 33 (13; sdk_gphone64_arm64) ERROR
  Disconnected , because no message in 30000 ms.
NativeScript / 33 (13; sdk_gphone64_arm64): Executed 1 of null (1 FAILED) DISCONNECTED (30.022 secs / 0 secs)

Reproduction

create a new project and test with jasmine

ns create test-project
...
cd test-project

ns test init
<select jasmine>
...

ns test android

Relevant log output (if applicable)

06 09 2022 14:27:50.945:WARN [NativeScript / 33 (13; sdk_gphone64_arm64)]: Adapter did not report total number of specs.
NativeScript / 33 (13; sdk_gphone64_arm64)  /absolute/Users/adamatri/Project/testp/node_modules/karma-jasmine/lib/boot.js?760d54bbca4f739f1f8b252c1636d76201cc4e88 at line 0 FAILED
	TypeError: global.addEventListener is not a function
NativeScript / 33 (13; sdk_gphone64_arm64): Executed 1 of null (1 FAILED) (0.018 secs / 0 secs)

Environment

OS: macOS 12.5.1
CPU: (10) x64 Apple M1 Max
Shell: /bin/bash
node: 16.16.0
npm: 8.15.1
nativescript: 8.3.2

# android
java: 11.0.14.1
ndk: Not Found
apis: 25, 26, 27, 28, 29, 30, 31, 32
build_tools: 27.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 32.0.0
system_images: 
  - android-22 | ARM EABI v7a
  - android-22 | Google APIs ARM EABI v7a
  - android-25 | Google APIs ARM 64 v8a
  - android-29 | ARM 64 v8a
  - android-30 | Google APIs ARM 64 v8a
  - android-30 | Google APIs Intel x86 Atom
  - android-30 | Google Play Intel x86 Atom_64
  - android-31 | ARM 64 v8a
  - android-31 | Google APIs ARM 64 v8a
  - android-31 | Google APIs Intel x86 Atom_64
  - android-32 | Google APIs ARM 64 v8a
  - android-33 | Google APIs ARM 64 v8a

# ios
xcode: 13.4.1/13F100
cocoapods: 1.11.3
python: 3.10.6
python3: 3.10.6
ruby: 2.6.8
platforms: 
  - DriverKit 21.4
  - iOS 15.5
  - macOS 12.3
  - tvOS 15.4
  - watchOS 8.5

Dependencies

"dependencies": {
  "@nativescript/core": "~8.3.0",
  "@nativescript/theme": "~3.0.2",
  "@nativescript/unit-test-runner": "^3.0.4"
},
"devDependencies": {
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
  "@nativescript/android": "8.3.1",
  "@nativescript/types": "~8.3.0",
  "@nativescript/webpack": "~5.0.6",
  "@types/jasmine": "4.0.3",
  "karma": "6.4.0",
  "karma-coverage": "2.2.0",
  "karma-jasmine": "5.1.0",
  "karma-nativescript-launcher": "0.4.0",
  "nyc": "15.1.0",
  "typescript": "~4.5.5"
}

Please accept these terms

@AdamAtri AdamAtri added the bug-pending-triage Reported bug, pending triage to confirm. label Sep 6, 2022
@SmailHammour
Copy link

Reverting karma-jasmine to v4 seems to fix this issue.

@rigor789 rigor789 added breaking-change and removed bug-pending-triage Reported bug, pending triage to confirm. labels Sep 21, 2022
@bitsnaps
Copy link

bitsnaps commented Oct 7, 2022

Got the same issue with message: TypeError: global.addEventListener is not a function using jasmine (initialized with ns test init jasmine), after running ns test android the default created test, using these versions:

ns: 8.3.3
    "@nativescript/unit-test-runner": "^3.0.4"
    "@nativescript/android": "8.3.1"
    "karma": "6.4.1",
    "karma-coverage": "2.2.0",
    "karma-jasmine": "5.1.0",
    "karma-nativescript-launcher": "0.4.0",
Majave: 10.14.6

P.S. Downgrading karma-jasmine to 4.0.2 solve the issue for now.

@CodeWitchJosie
Copy link

I had to downgrade Karma again after updating all my dependencies to latest. Is this still expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants