Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,18 @@ TESTOMATIO=11111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" --no-de
This option could also be set via environment variable `TESTOMATIO_NO_DETACHED=1`.
If you don't want to pass it each time, create .env file in the root dir of your project with this variable set.

## Partial Import

If your project is large and you want to import (or re-sync) only a subset of tests from a specific directory, without affecting the rest of the tests already imported into Testomat.io, use the `--partial` option together with `-d`:

```
TESTOMATIO=1111111 npx check-tests CodeceptJS "**/*{.,_}{test,spec}.js" -d ./tests/api --partial
```

This is equivalent to combining `-d ./tests/api` with `TESTOMATIO_PREPEND_DIR=./tests/api`: only tests found inside `./tests/api` are scanned and imported into the matching folder in Testomat.io, while tests outside that directory are left untouched and are not marked as detached.

`--partial` requires the `-d` option; without it the command will fail.

## Synchronous Import

By default `check-tests` doesn't wait for all tests to be processed. It sends request to Testomatio and exits. To wait for processing to finish use `--sync` option.
Expand Down
12 changes: 11 additions & 1 deletion bin/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,22 @@ async function mainAction(framework, files, opts) {
.catch(err => console.log('Error in creating test document', err));
}
if (apiKey) {
if (opts.partial && !opts.dir) {
console.log(' ⚠️ --partial requires -d option to specify directory');
return;
}

const reporter = new Reporter(apiKey.trim(), framework, workDir);
reporter.addTests(decorator.getTests());
const resp = reporter.send({
sync: opts.sync || opts.updateIds,
create: opts.create || false,
noempty: !opts.empty,
branch,
'no-detach': process.env.TESTOMATIO_NO_DETACHED || !opts.detached,
'no-detach': process.env.TESTOMATIO_NO_DETACHED || !opts.detached || opts.partial,
structure: opts.keepStructure,
force: opts.force || false,
...(opts.partial && { dir: workDir }),
}); // async call

if (opts.sync) {
Expand Down Expand Up @@ -200,6 +206,10 @@ program
.option('--test-alias <test-alias>', 'Specify custom alias for test/it etc (separated by commas if multiple)')
.option('--exclude <pattern>', 'Glob pattern to exclude files from analysis')
.option('--require-ids', 'Fail build if tests are missing Testomat.io IDs')
.option(
'--partial',
'Upload tests from -d directory without marking other tests as detached (sets TESTOMATIO_PREPEND_DIR to -d value)',
)
.action(mainAction);

// Pull command
Expand Down
21 changes: 11 additions & 10 deletions cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,17 @@ TESTOMATIO=your-api-key npx check-tests push -d ./tests --files "**/*.md"

### Testomat.io Integration

| Option | Description | Default |
| ----------------------------- | ------------------------------------------------------------- | ------- |
| `--sync` | Import tests to Testomat.io and wait for completion | false |
| `--no-detached` | Don't mark all unmatched tests as detached | false |
| `--update-ids` | Update test and suite with Testomat.io IDs | false |
| `--create` | Create tests and suites for missing IDs | false |
| `--keep-structure` | Prefer structure of source code over structure in Testomat.io | false |
| `--no-empty` | Remove empty suites after import | false |
| `--clean-ids` | Remove Testomat.io IDs from test and suite | false |
| `--purge, --unsafe-clean-ids` | Remove Testomat.io IDs without server verification | false |
| Option | Description | Default |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `--sync` | Import tests to Testomat.io and wait for completion | false |
| `--no-detached` | Don't mark all unmatched tests as detached | false |
| `--update-ids` | Update test and suite with Testomat.io IDs | false |
| `--create` | Create tests and suites for missing IDs | false |
| `--keep-structure` | Prefer structure of source code over structure in Testomat.io | false |
| `--no-empty` | Remove empty suites after import | false |
| `--clean-ids` | Remove Testomat.io IDs from test and suite | false |
| `--purge, --unsafe-clean-ids` | Remove Testomat.io IDs without server verification | false |
| `--partial` | Import only tests from `-d` directory into the matching folder, without marking tests outside it as detached (requires `-d`; equivalent to `-d <dir>` + `TESTOMATIO_PREPEND_DIR=<dir>`) | false |

### Test Analysis Options

Expand Down
Loading