Docs / Optional Mapping Tests

Test and deploy a mapping safely

An 850 purchase order maps correctly today. Before editing that map, keep a small sample and the output you expect. The next time you change it, a saved test can tell you whether that behavior changed.

No scenario, external Git repository, or CLI is required.

Tests are optional. You can operate an integration with a partner and its required mappings. Add tests when you want repeatable checks before changing a working map.

Try it without touching a live map

Use Keep a mapping working for a guided mistake-and-repair exercise with a temporary map and synthetic purchase order. Finishing or closing restores your original workspace. Practice cases are not saved to your workspace, and nothing is sent or deployed. If you have not written a map yet, start with Map an 850 to JSON.

Try a compact purchase order

ISA declares | as the element separator and ! as the segment terminator in this compact 004010 850. Open salesOrder.map in the mapper demo, select Run, and paste the document into X12 input. Keep the spaces in ISA so its fields stay at their fixed positions.

ISA|00|          |00|          |ZZ|MODERNEDI      |ZZ|WORKSPACEDEST  |260413|1200|U|00401|000000001|0|T|>!GS|PO|MODERNEDI|WORKSPACEDEST|20260413|1200|1|X|004010!ST|850|0001!BEG|00|SA|PO0001||20260413!REF|DP|12!PO1|1|2|EA|10||IN|ITEM-001!CTT|1!SE|6|0001!GE|1|1!IEA|1|000000001!

Replace the map source with the expression below and select Run map. The output is PO0001. Select Show used fields to see the value read from BEG03.

print(ST->BEG(03))

1. Save one useful example

To keep saved cases, sign in to your workspace and open an editable mapping draft. The ordinary anonymous demo does not show saved-case controls. For temporary practice without an account, use the Keep a mapping working lesson above; closing or finishing it removes its practice cases.

  1. Open an editable map and run a sample.For an incoming 850, load a representative X12 order and use Run map. For an outgoing map, choose your source document and parameters, then use Run transform. Inspect the business values before treating the result as correct.
  2. Expand Saved test cases (optional).Choose Save latest Run as test. This captures the run's input, parameters or transaction selection, and exact output. It does not turn every sample file in Explorer into a test.
  3. Review the data, then Save in draft.Give the case a useful name, such as “850 with two order lines.” Remove customer data and secrets from the input and expected output. Review captured parameters too; if they need changing, update the Run inputs and capture a new result. Confirm that the example is safe to keep in configuration history.

Saving a case changes only the draft. When you apply it later, its fixtures enter configuration history and any connected Git repository. Deleting it later does not erase older history. Public Mapper share links omit saved cases.

Outgoing cases keep the exact input content type from Run, including vendor types such as application/vnd.example+json and parameters such as application/xml; charset=utf-8. Rerunning uses that saved type and input, even if you later change the Run panel. JSLT accepts JSON; XSLT accepts JSON, XML, or text. The selected engine validates the input format.

To investigate a live incoming mapping failure, open Live activity and choose Load input into Run. If the retained message contains several transactions, ModernEDI loads only the failed transaction, keeping its original ISA/GS headers and adjusting the envelope counts. This diagnostic copy does not change the retained message or replay any traffic. If the failed transaction cannot be identified uniquely, your existing Run input is left untouched.

2. Check an edit against that example

Suppose the purchase-order number comes from ST->BEG(03). Reading ST->BEG(02) instead can still produce valid JSON, but puts the order-type code where the PO number belongs. In a practice draft, make that change and choose Run saved cases. The case should fail even though the map can execute.

Expand Compare exact text to see the first difference and both outputs. Restore the correct expression and rerun the case. Do not replace the expected output just to make a failure disappear: decide whether the new behavior is actually intended.

PASSED means the generated text exactly matched the saved expectation and any selected X12 validation passed. FAILED means at least one check failed. ERROR means execution or a requested check did not produce a usable result. Whitespace, line endings, order, and delimiters count. Validation and exact-output tests answer different questions; neither is a substitute for checking meaningful business values.

When two outputs look identical, check the line-ending counts beneath Expected output and Actual output. A Windows CRLF and a single LF both display as a new line. Their counts and the first difference help you see which text the case actually compared.

When validating Run output against an attached schema, the result applies only to that output and schema. Selecting or editing another schema, changing the output, or reopening the validation dialog requires a fresh check; an earlier pending response cannot validate the new selection.

Also validate generated X12 (outgoing maps)

For an outgoing JSLT or XSLT case, select Review / edit → Also validate generated X12. ModernEDI uses the map's existing document type and X12 version, the same document preparation as outgoing preview/send, and the existing X12 validator. Document bodies receive a synthetic envelope for validation without changing the exact output you compare. Leave this off for partial fragments that are not intended to form a complete document. Nothing is sent.

In Run, Generated X12 shows formatting issues in the raw transform output. If the output body ends with CTT*2, the validator can supply the final ~ when preparing the envelope and pass the resulting document. Run still flags the missing terminator in the raw text. Save CTT*2~ in the expected output so the exact-text comparison catches a missing terminator.

After Run transform, select an issue under Generated X12 in Problems. For a field error, the preview selects the value on the affected segment, even when the segment repeats. Click the field to inspect its source trace when available. Fix the source data or transform, then rerun to check the corrected output.

For example, an expected invoice might itself omit a required field. Its exact-output comparison can pass while X12 validation fails. The editor and server evidence show those outcomes separately. Valid X12 still does not prove the business values are right or a partner accepted the document.

The optional validateX12: true case property is stored with the fixture in configuration and Git. Browser and API server verification use the same rules; the server checks the exact frozen syntax tree and retains only outcomes and hashes. Changing the option requires fresh verification, but does not by itself redeploy the mapping. Incoming maps do not need this option.

Add a few examples for important variations: several lines, an omitted optional address, or an outgoing parameter. In the ASN examples, change shipmentId and check BSN02 (Shipment Identification). This business identifier is separate from ST02, the transaction control number supplied by the envelope. Each map supports up to 10 cases, 65,536 characters per input or expected output, and 256 KiB for its complete case data.

The outgoing goods-order examples require a nonempty line collection before generating X12: a JSON lines array containing only objects, or XML <lines> containing only <line> records. An unexpected entry fails with its position; JSON indexes start at zero. Line fields such as unitPrice and quantity take scalar values. If your source supplies a structured amount, use the intended scalar field or compute the decimal explicitly. Use Run transform to try malformed input and inspect the rejection diagnostic. Saved cases currently compare successful output; they cannot assert an expected execution error. A rejected transform is reported as ERROR, not a passing negative test. Save correct single-line and multi-line orders as exact-output cases. X12 validation cannot detect a source line that a transform silently skipped.

3. Review the change, not just the green result

In your signed-in workspace, use Review & deploy when the draft is ready. Review the map source, settings, and any added, changed, or removed cases. A saved draft is not the live map. If another editor or repository changed the configuration, resolve the reported conflict and prepare a new review.

If you use scenarios, this review also shows affected conversations. A pass on an older binding describes that older configuration; it does not verify the new map. You do not need to create a scenario to review or deploy a mapping.

4. Optionally retain a server verification result

Choose Verify saved cases on server in the review. ModernEDI runs the cases from that exact reviewed configuration, not from a later editor draft. The retained result identifies the reviewed plan, source, cases, evaluator, and syntax tree. Reopening an unchanged review retrieves that result.

An incoming saved case can contain several document types in one X12 interchange. ModernEDI validates the complete input and maps only the saved transaction selection, which must match the mapping's document type and X12 version. Server verification reads every required syntax tree from the same pinned catalog; it does not silently substitute another version. The original input and selection remain part of the test evidence.

While the review is open, result status updates automatically, including after a temporary connection failure. A completed result is also rechecked for changed dependencies. These checks never rerun the cases or change the review you approved. If evidence becomes stale, prepare a new review and explicitly verify it again.

Ordinary Run and Run saved cases feedback stays in the editor session. Server verification is the optional durable record. It has a 30-second suite deadline, supports cancellation, and shares a workspace limit of one active verification and 30 starts per hour with API verification. The latest 200 results are retained for up to 90 days.

A pass checks the saved examples in the backend evaluator. It does not prove live runtime activation, AS2 delivery, or partner acceptance. If a tested dependency changes or cannot be checked, the old result is labeled stale.

If your configuration contains saved conversation tests, this action runs the whole proposed configuration, including those offline cross-document checks. You can require its current passing result during Apply using the displayed checkbox; failed or stale selected evidence blocks Apply. Mapping-only verification remains available without a scenario, and tests remain optional.

If you connect an external repository, its owner can separately enable saved-case checks before automatic imports. That option runs the same cases against the incoming configuration and holds an import unless they pass. Mapping-only authoring and ordinary browser deployment remain available without it.

5. Deploy, then check activation and history

Confirm the reviewed deployment when you are ready. Wait for runtime activation before expecting new traffic to use the map. Open Change history to inspect the operation, the saved configuration version, and any associated server test result. Use Download verification evidence if you need to retain that result independently.

Changing only cases does not republish the runtime mapping or refresh scenario bindings. Case inputs and expectations remain configuration source; execution results are separate evidence, not files written into your repository.

Choose the next benefit you need

Follow one complete worked example: the same PO0001 sample connects a mapping test, an optional order/invoice scenario, and exact configuration history.

Use a scenario to check whether related documents and acknowledgments form the right business conversation. Use external Git to synchronize applied configuration with your repository. For optional CI checks, the configuration runner verifies these same saved cases against a complete proposed configuration; an explicit --verification-run-id can require that exact passing result during apply.

The Integration API reference documents spec.regressionCases, and the generated case JSON Schema supports editor tooling. You can keep using the browser and stop at any point in this progression.