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

Implement automatic tests #30

Open
diegodlh opened this issue Jan 29, 2021 · 5 comments
Open

Implement automatic tests #30

diegodlh opened this issue Jan 29, 2021 · 5 comments
Assignees

Comments

@diegodlh
Copy link
Owner

No description provided.

@Dominic-DallOsto
Copy link
Collaborator

Do you have any particular format in mind? Zotero looks to use a complex custom setup to test the full program. Better BibTeX uses a Python testing library. Zotxt uses JS and Mocha.

@diegodlh
Copy link
Owner Author

Hi, Dominic! Thank you for providing that information. I have little to none experience with automatic software testing. So far I have only written some very basic unit tests for the wikibase-edit project, which uses Mocha, and Should.js as assertion library.

I'm interested in the Hypothesis web annotation project, to which I have made some contributions, and I understand that their client uses Karma and Mocha, and Chai.js as assertion library.

The project I'm currently working with, Wikipedia's Web2Cit, will probably be written mostly in JavaScript. A part will run on users' browsers, and another part on a backend server, probably running Node.js.

Therefore, I think I would prefer (so that I can use what I learn in my other projects) a JavaScript testing infrastructure, such as Mocha. Although I don't know whether that would work to test an extension running inside Zotero... What do you think?

@Dominic-DallOsto
Copy link
Collaborator

I had a quick look at some options. Using a JS based testing library makes sense, yeah. From what I can tell Mocha and Jest are two popular options and integrate nicely with Node. It could also be nice to integrate with codecov through Github actions (to automatically run tests when someone commits / adds a pull request), but not sure how much extra effort that would be.

From some quick searching, you can test React components with Jest and more or less with any framework. Testing the extension in a live Zotero environment would I guess be more difficult, but maybe that could be a next step after covering the main functions of Cita?

@Dominic-DallOsto
Copy link
Collaborator

I looked into this quickly, using Mocha, Should.js, and nyc. But because Cita is tightly integrated with Zotero, it's not really possible to import any of the files to test in isolation because they depend on Zotero or firefox components. I think we'd therefore have to do something like in Zotero itself, where they launch a debug version of Zotero and firefox and then run normal js tests.

@Dominic-DallOsto
Copy link
Collaborator

I got this to work for another project using a docker image, installing Zotero in it and then using XVFB as a virtual display so Zotero can run in the docker container.

I think we could do something similar for Cita, but use NPM and Mocha/Jest/whichever to do the tests.

@diegodlh diegodlh changed the title Implement unit tests Implement automatic tests Feb 10, 2022
@Dominic-DallOsto Dominic-DallOsto self-assigned this Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants