livechat / chat-widget-adapters

This project contains a set of libraries for adapting LiveChat Chat Widget with certain frontend frameworks
https://developers.livechat.com
MIT License
24 stars 8 forks source link

Updated supported Angular major version #60

Closed ectuser closed 1 year ago

ectuser commented 1 year ago

Type of change

Packages

Issue

https://github.com/livechat/chat-widget-adapters/issues/61

Update Angular peer dependency to the latest v15.

Description

Add Angular 14 to @livechat/widget-angular supported peer dependencies.

Tested in the Angular 15 app. Works correctly, no issues spotted

walaszczykm commented 1 year ago

Hello @ectuser, thank you very much for the PR! 🙌 Would you be able also to update the Angular version to the newest one in our example app used for tests? It's located in examples/angular; that way, we can verify that everything is working on the prepared setup using automated tests. 🙂

ectuser commented 1 year ago

Hello @walaszczykm! Thank you for your response! I migrated the example Angular app to the v14 as well as widget-angular dependencies. Then tests started to failing because of some jest issue: Cannot find module '@angular/core/testing' from 'node_modules/jest-preset-angular/build/config/setup-jest.js'. Updating jest-preset-angular and jest packages introduced other issues. For now, I do not know how to fix it. If you have time, can you please take a look?

walaszczykm commented 1 year ago

Thanks, @ectuser 🙌 I will take a look into that, don't worry 🙂

walaszczykm commented 1 year ago

Ok @ectuser, it looks like an issue with imports resolution inside jest-preset-angular/setup-jest, which tries to import @angular/core/testing using require, which, after updating the Angular version, fails as the module's package.json now uses exports keyword without nested package.json files.

For those tests to set up for Jest, we need zone.js so we can get around this issue by importing it directly instead of the entire setup script. That way, simply replace this line in packages/widget-angular/jest.setup.js:

import 'jest-preset-angular/setup-jest'

with

import 'zone.js'

and everything should work as expected and tests should pass (tested on my side locally).

Just please do not uninstall the jest-preset-angular as it is still used as preset in jest.config.json we only want to simplify the setup script 🙂