← All Exercises

Generate a Test Matrix with Exclusions

basicjavascript~20min

Background

Browser matrices grow multiplicatively. Recording unsupported pairs as data avoids both over-testing impossible combinations and silently skipping real ones.

Problem

Expand browser, operating system and locale dimensions into a combination matrix, remove explicitly unsupported pairs, and report the totals plus a sample of selected cases.

Input

JSON object: { dimensions: { [name]: string[] }, excludePairs?: [{ [dimension]: value }] }

Output

JSON object: { total, selected, sample }

Sample tests

Sample 1

Input: {"dimensions":{"browser":["chromium","firefox"],"os":["linux","mac"]},"excludePairs":[{"browser":"firefox","os":"mac"}]}
Expected: {"total":4,"selected":3,"sample":[{"browser":"chromium","os":"linux"},{"browser":"chromium","os":"mac"},{"browser":"firefox","os":"linux"}]}

Sample 2

Input: {"dimensions":{"locale":["en","zh-cn"]}}
Expected: {"total":2,"selected":2,"sample":[{"locale":"en"},{"locale":"zh-cn"}]}

Your solution

Learning objective

Generate a reviewable test matrix instead of hand-maintained browser lists.