MCPcopy Index your code
hub / github.com/adobe/react-spectrum / testDocs

Function testDocs

scripts/testDocs.js:96–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94}
95
96async function testDocs() {
97 let server;
98 let browser;
99 let messages = [];
100 let currentPage = '';
101
102 const browserType = parseArgs();
103 console.log(`Using ${browserType} browser for testing`);
104
105 try {
106 server = await startServer();
107 await waitForServer(server.baseUrl);
108
109 const pageLinks = await getPageLinks().then(links =>
110 links.map(link => `${server.baseUrl}${link}`)
111 );
112 console.log(`Found ${pageLinks.length} pages to test`);
113
114 switch (browserType) {
115 case 'firefox':
116 browser = await firefox.launch();
117 break;
118 case 'webkit':
119 browser = await webkit.launch();
120 break;
121 default:
122 browser = await chromium.launch();
123 }
124
125 const context = await browser.newContext();
126
127 context.on('console', msg => {
128 const msgUrl = msg.location().url;
129 if (
130 msgUrl.startsWith(server.baseUrl) &&
131 (msg.type() === 'error' || msg.type() === 'warning')
132 ) {
133 console.log(`${msg.type().toUpperCase()} on ${currentPage}: ${msg.text()}`);
134 messages.push({type: msg.type(), path: currentPage, text: msg.text()});
135 }
136 });
137
138 for (let i = 0; i < pageLinks.length; i++) {
139 const url = pageLinks[i];
140 currentPage = new URL(url).pathname;
141 console.log(`Testing page (${i + 1}/${pageLinks.length}): ${currentPage}`);
142
143 const page = await context.newPage();
144
145 try {
146 const response = await page.goto(url, {
147 waitUntil: 'networkidle',
148 timeout: 10000
149 });
150
151 if (!response.ok()) {
152 console.error(
153 `Failed to load ${currentPage}: ${response.status()} ${response.statusText()}`

Callers 1

testDocs.jsFile · 0.85

Calls 7

waitForServerFunction · 0.85
getPageLinksFunction · 0.85
pushMethod · 0.80
parseArgsFunction · 0.70
startServerFunction · 0.70
closeMethod · 0.65
filterMethod · 0.65

Tested by

no test coverage detected