1

This question is related to Testing Library for React and unittest for Python.

I'd like like to have a single file that contains unit tests and integration tests for a component, and be able to target each kind of test individually. It sounds like pytest has this functionality where you can specify with an @ (or maybe it was []) before the test class that it is a "unit-test" or "integration-test".

Is something similar possible with unittest and Testing Library, or is the only option in the file naming convention: component.ut.js, component.it.js, component.ut.py, component.it.py, etc.?

3
  • 1
    Those are two different things - unittest is the Python standard library's xUnit test framework, Testing Library is a set of helpers/utilities for interacting with UIs. Whatever your actual test runner/framework is (e.g. Jest) will drive how exactly you can segment your tests into different groups to run separately. In unittest you would e.g. conditionally skip tests depending on which group you wanted them in: docs.python.org/3/library/….
    – jonrsharpe
    Oct 1 '21 at 16:16
  • Right, I'm aware they are two different things if it wasn't clear from my post and obviously that determines how segmenting is done. I'm primarily concerned with the segmenting itself with these two libraries. Your link helped to answer unittest, I'll keep digging on Testing Library.
    – cjones
    Oct 1 '21 at 16:24
  • Testing Library doesn't do the test discovery or running so you're looking in the wrong place.
    – jonrsharpe
    Oct 1 '21 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.