This directory contains automated tests for the contact form template to ensure all functionality works as expected.
# Run all tests (HTML validation + automated tests)
npm test
# Run only HTML validation
npm run test:html
# Run automated test suite
npm run test:serve
# Open browser-based tests
npm run test:browser
Before running tests, ensure you have Node.js installed and run:
npm install
This will install the required testing dependencies, including html-validate.
run-tests.js - Automated Test SuiteA Node.js script that performs comprehensive automated testing of the contact form template.
What it tests:
Usage:
node tests/run-tests.js
Expected Output:
╔════════════════════════════════════════════════════════════╗
║ Contact Form Template - Automated Test Suite ║
╚════════════════════════════════════════════════════════════╝
✓ HTML file exists and is readable
✓ HTML5 doctype is present
✓ UTF-8 charset is declared
...
All tests passed!
test-contact-form.html - Browser-Based TestsAn interactive HTML test page that runs tests in a real browser environment.
Features:
What it tests:
Usage:
Open tests/test-contact-form.html in your web browser, or use:
npm run test:browser
The tests will run automatically on page load, or you can click “Run All Tests” to re-run them.
These tests verify the HTML structure is valid and well-formed:
These tests ensure all required form fields are present and properly configured:
These tests verify the form validation is working correctly:
These tests ensure the form meets accessibility standards:
These tests verify code quality and best practices:
The tests are automatically run via GitHub Actions on every push and pull request. The workflow file is located at .github/workflows/validate-html.yml.
| Category | Tests | Status |
|---|---|---|
| HTML Structure | 5 | ✅ |
| Dynamics 365 | 2 | ✅ |
| Form Fields | 9 | ✅ |
| Validation | 6 | ✅ |
| Styling & UI | 4 | ✅ |
| Accessibility | 2 | ✅ |
| Code Quality | 3 | ✅ |
| Total | 31 | ✅ |
run-tests.jsrunner.test('Test description', () => {
runner.assert(condition, 'Error message if test fails');
});
test-contact-form.html// In the appropriate test function
const element = iframeDoc.querySelector('#element-id');
addResult('Test Name', !!element, 'Optional error message');
Solution: Ensure you’re running tests from the project root directory.
cd /path/to/Dynamics-365-Customer-Insights-Form-Templates
npm test
Solution: Make sure you’re opening test-contact-form.html from a web server or using the file:// protocol with proper CORS settings. The relative path ../templates/contact-form.html must be accessible.
Solution: Install Node.js and run npm install first.
Planned improvements for the test suite:
When adding new features to the contact form:
Last Updated: October 31, 2025
Test Suite Version: 1.0.0