I need to write unit tests for our pdf annotating software that we have built with DocumentViewer.
There is no documentation for this process.
In the main component for the document viewer, we set Core.setWorkerPath() from index.html, then set the document viewer with this.documentViewer = await new Core.DocumentViewer().
However, when trying to test, I cannot even past the test initialization process because errors are thrown, saying things such as documentViewer.getAnnotationManager is not a function, even when I set it in the describe function. This has been a long and tedious process losing days trying to figure it out, so I hope some progress can be made by posting here. Thank you.
That is not helpful because they are testing with instance and we are not using it that way. I am looking for ways to figure this out without using instance. I’m sure there are others who need to test this as well. Please help provide helpful solutions.
I have managed to get documentViewer to not throw an error, but now it is complaining that annotationManager is undefined. In our jest settings file I have included which seems to work. Setting annotation manager here or in the test file does not yield different results. global.window.Core = { setWorkerPath: jest.fn(), DocumentViewer: jest.fn(), };
Core.setWorkerPath("/webviewer"); let documentViewer = await new Core.DocumentViewer();
This works fine and no further errors are thrown about core or document viewer,
the only error being thrown now is about the annotation manager being undefined. If i do annotationManager = documentViewer.getAnnotationManager();
or even