Skip to content

Grader: file-contains

PropertyValue
Determinismstatic
Costlow
Portabilityt1-universal
Referencereference-free
Temporal scopetrajectory-level
Score kindcode
graders:
- type: file-contains
config:
path: "add.test.js"
value: "expect"
FieldTypeRequiredDescription
pathstringYesFile path (or glob) to check
valuestringYesText that must appear in the file
negatebooleanNoWhen true, passes when the value is NOT found

Use file-not-contains as a shorthand for negate: true:

graders:
- type: file-not-contains
config:
path: "*.csproj"
value: "packages.config"

This is equivalent to type: file-contains with negate: true.

  1. Finds files matching path in the workspace using glob
  2. Reads file contents
  3. Checks if the file contains value (case-sensitive)

Passes when the value is found in at least one matching file (or NOT found if negated). Fails otherwise.

✔ 'expect' found in add.test.js
✘ 'expect' NOT found in add.test.js
✘ No files matching 'add.test.js' found