Skip to main content

Module test_code

Module test_code 

Source
Expand description

Which functions are tests, so that --compare measures tests and code apart and pairs a test only with a test.

Most languages keep tests in files of their own, named by convention (is_test_path): *_test.go, test_*.py, *.test.ts, *Test.java, *Tests.swift, *_spec.rb, or folders such as tests/, __tests__/, src/test/ and MyAppTests/. Two kinds of test live among the code ([inline_test]): Rust tests, in a #[cfg(test)] module or under a #[test] attribute, and JavaScript and TypeScript test cases, it('title', () => …), which Vitest runs from source files too.

Functions§

is_test_path
Whether path names a test file by the conventions of the languages jscpd compares. path starts at the compared folder itself (tests/copy.rs when the folder is tests/), so a folder given on the command line counts as well as the folders below it.