• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/javascript/subsystems/nodejstest.py
1
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
from pathlib import PurePath
×
UNCOV
7
from typing import cast
×
8

UNCOV
9
from pants.backend.javascript.package_json import PackageJsonTarget
×
UNCOV
10
from pants.build_graph.address import Address
×
UNCOV
11
from pants.core.goals.test import Test
×
UNCOV
12
from pants.core.target_types import FileTarget
×
UNCOV
13
from pants.core.util_rules.distdir import DistDir
×
UNCOV
14
from pants.option.option_types import SkipOption, StrOption
×
UNCOV
15
from pants.option.subsystem import Subsystem
×
UNCOV
16
from pants.util.docutil import bin_name
×
UNCOV
17
from pants.util.strutil import help_text, softwrap
×
18

19
_EXAMPLE = """\
20
Consider a directory-layout:
21

22
```
23
├── BUILD
24
├── src/
25
│   ├── BUILD
26
│   ├── test/
27
│   │   ├── BUILD
28
│   │   └── index.test.js
29
│   └── index.js
30
└── package.json
31
```
32

33
where package.json contains
34

35
```json title=\"package.json\"
36
{
37
    ...
38
    "scripts": {
39
        "test": "mocha"
40
    },
41
    "devDependencies: {
42
        ...
43
    }
44
}
45
```
46
"""
47

48

UNCOV
49
class NodeJSTest(Subsystem):
×
UNCOV
50
    options_scope = "nodejs-test"
×
UNCOV
51
    help = cast(
×
52
        str,
53
        help_text(
54
            f"""
55
        Options for package.json script configured tests.
56

57
        Your preferred test runner is configured via the `package.json#scripts.test`
58
        field.
59

60
        The only expectation from pants is that the `test` script can
61
        accept a variadic number of path arguments, relative to the package.json,
62
        and that any configuration files are `{FileTarget.alias}` dependencies
63
        to the `{PackageJsonTarget.alias}`.
64

65
        Simple example:
66

67
        {{}}
68

69
        Executing `{bin_name()} {Test.name} src/test/index.test.js`
70
        will cause the equivalent of `mocha src/test/index.test.js` to run.
71
        """
72
        ),
73
    ).format(_EXAMPLE)
UNCOV
74
    name = "Node.js tests"
×
75

UNCOV
76
    skip = SkipOption("test")
×
77

UNCOV
78
    coverage_output_dir = StrOption(
×
79
        default=str(PurePath("{distdir}", "coverage", "js", "{target_spec}")),
80
        advanced=True,
81
        help=softwrap(
82
            """
83
            Path to write the NodeJS coverage reports to. Must be relative to the build root.
84

85
            Replacements:
86

87
            - `{distdir}` is replaced with the Pants `distdir`.
88

89
            - `{target_spec}` is replaced with the address of the applicable `javascript_test` target with `/`
90
            characters replaced with dots (`.`). Additional batch information is included in `target_spec`, when
91
            batching is used.
92
            """
93
        ),
94
    )
95

UNCOV
96
    def render_coverage_output_dir(
×
97
        self, distdir: DistDir, addresses: tuple[Address, ...]
98
    ) -> PurePath:
99
        results_file_prefix = addresses[0].path_safe_spec
×
100
        if len(addresses) == 1:
×
101
            target_spec = results_file_prefix
×
102
        else:
103
            target_spec = f"batch-of-{results_file_prefix}+{len(addresses) - 1}-files"
×
104
        return PurePath(
×
105
            self.coverage_output_dir.format(distdir=distdir.relpath, target_spec=target_spec)
106
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc