An automation test framework for testing W3C WebNN Samples and Microsoft WebNN Demos.
$ npm install
$ cp env.example.json env.json
env
:'debug'
for local development.'production'
for production model and the test result will be sent via email.hostname
: Identify yourself.proxy
: Set the proxy server, which is usually needed.emailService
: Edit the email config according to your server.
The config.json file can be automatically generated using the command:
npm run generate-config
Run with -h
to see the help message.
$ npm run generate-config -- -h
Usage: npm run generate-config -- [options]
Generate config for webnn sample tests
Options:
-b, --browser <browser> The browser to use (choices: "chrome_canary", "chrome_dev", "chrome_beta", "chrome_stable", "edge_canary", "edge_dev", "edge_beta", "edge_stable", default: "chrome_canary")
-d, --devices <devices...> The devices to use (choices: "cpu", "gpu", "npu", default: ["cpu","gpu","npu"])
-e, --backend <backend> The backend to use (choices: "ort", "tflite", default: "ort")
-o, --output <path> The output config file path (default: "config.json")
-h, --help display help for command
You can also manually adjust the parameters in config.json to fit your specific needs.
browser
: Choose the browser to run the test. Options includechrome_canary
,chrome_dev
,chrome_beta
,chrome_stable
,edge_canary
(except on Linux),edge_dev
,edge_beta
,edge_stable
.browserUserData
: Browser user data includes browser cache. When webnn flag is enabled and browserUserData is used, script won't test wasm or webgl backends.browserUserDataPath
: The browserUser Data
folder path supports manual setting by users and is empty by default.browserAppPath
: The browserApplication
folder path supports manual setting by users and is empty by default.headless
: Display chrome UI.timeout
: Browser page waiting time (ms), if the test device performance is poor, please set a larger value.imageCompareThreshold
: Images matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive. 0.1 by default.samplesBasicUrl
: URL of WebNN samples.samplesUrl
: Each sample URL:samplesBasicUrl + samplesUrl
.samples
: WebNN samples config.developerPreview
: WebNN developer preview demo config.
$ npm test
Get all supported samples from help message
$ npm test -- -f
Using config file: config.json
Available filters:
┌─────────┬──────────────────────────────────────────────────────────────────────────┐
│ (index) │ Values │
├─────────┼──────────────────────────────────────────────────────────────────────────┤
│ 0 │ 'samples-image-classification-cpu-fp32-mobileNetV2' │
| ... | ... │
└─────────┴──────────────────────────────────────────────────────────────────────────┘
Specify the sample with -f
or --filter
option. Multiple samples can be specified by separating them with spaces.
$ npm test -- -f samples-image-classification-cpu-fp32-mobileNetV2
Node
NOTE: The command
npm run [command] -- [options | args]
may not work correctly inPowerShell
on Windows with certain Node.js versions. It has been tested successfully on Node.js22.11.0
, but may fail on later versions until fixing issue 7375. If you encounter issues, try running it in a different terminal, such asGit Bash
.
Windows / Linux / MacOS
chrome_canary / chrome_dev / chrome_beta / chrome_stable / edge_canary / edge_dev / edge_beta / edge_stable
- edge_canary is not available on Linux.