farmOS / field-kit

A modular, offline-first companion app to farmOS.
https://farmOS.org
GNU General Public License v3.0
62 stars 39 forks source link

Fix test runner (Mocha) #482

Open jgaehring opened 2 years ago

jgaehring commented 2 years ago

As I mentioned briefly in https://github.com/farmOS/farmOS-client/issues/481#issuecomment-1010112354, our test framework, Mocha, has been broken for a little while now. This happened possibly as far back as the "monster commit" (59c3f30) that first integrated 2.x changes, or more likely somewhere after alpha.1 but definitely no later than alpha.3 (5f6d629). We only had 2 or 3 unit tests anyways, so this isn't a huge concern, but it would be best to get this back up and running before beta release.

Since I switched over to Vite, I've totally jettisoned the mocha-webpack integration we were using to precompile source prior to testing, so we'll need some kind of alternative to that at the very least. And since we're reevaluating that, and we only have unit tests at the moment, I figure it might be worth considering what test frameworks/runners are available with Vite and Vue 3 going forward. I'll do a link dump at the end of this, but I'll highlight the recommendation from the SFC Tooling section of the Vue 3 docs:

If using Vite, we recommend Cypress as the test runner for both unit and e2e tests. Unit tests for Vue SFCs can be done with the Cypress Component Test Runner.

It looks like Mocha and Jest are still the most prominent choices of framework for Vue 3, so I'd probably elect to keep Mocha rather than use another Facebook product. So I guess then the biggest decision is between Cypress and Puppeteer, with a slight lean towards Cypress w/o having investigated further. Although I suppose just for the unit tests we could also just write a simple node script to precompile everything before testing.

One final consideration is Chromatic, which I had previously set up as our one GitHub action, but I've already removed it on my vite working branch, and I'll want to reevaluate whether to add it back when I consider Storybook in general, which I'll open a separate issue for.

Aforementioned link dump:

jgaehring commented 1 year ago

I have removed these packages from devDependencies in 68f716f as a part of #517:

{
    "@vue/test-utils": "^2.0.0-rc.18",
    "chromatic": "^6.3.4",
    "expect": "^27.4.6",
    "jsdom": "^15.2.1",
    "jsdom-global": "^3.0.2",
    "mocha": "^9.1.3"
}

This is mostly to silence all the upgrade notices for the stale dependencies until I come back to fix this stuff.