Automated UI Test for SharePoint Solutions

On this page, you can find some related references for the “Automated UI Test for SharePoint Solutions” session which Elio presented together with Melanie Culver.

Feedback

If you want, you can provide feedback via the following form: feedback form.

Tools

Recorders

Other Tools

Code snippets

node-sp-auth authentication for Puppeteer

import * as spauth from "node-sp-auth";
const data = await spauth.getAuth(pageUrl, {
username: username,
password: password,
});

Combining Puppeteer and Jest

test('Should load the page', async (done) => {
if (page) {
await page.goto(configObj.pageUrl, {
waitUntil: 'networkidle0’
});
expect(page).not.toBeNull();
expect(await page.title()).not.toBeNull();
expect(await page.title()).toBe("Automated UI Tests - Home");
done();
}
}, 30000);
/**
* Start of the other page tests
*/
test('Check if caption element is present in the web part', async (done) => {
const elm = await page.$('.caption’);
expect(elm).not.toBeNull();
done();
}, 5000);

HTML sample for testing with custom attributes

<div className="{styles.caption}" data-ui-test-id="caption">
<p data-ui-test-id="caption-title">
<b>{item.title}</b>
</p>
<p data-ui-test-id="caption-description">
<i>{item.description}</i>
</p>
</div>

The test code:

/**
* Start of the other page tests
*/
test('Check if caption element is present in the web part', async (done) => {
const caption = await page.$('div[data-ui-test-id="caption"]’);
expect(caption).not.toBeNull();
done();
}, 5000);

Elio Struyf

I build developer tools · Microsoft 365 architect · Speaker

Loading...

Let's build together

All your AI coding agents in one window

Present from VS Code

Manage content in VS Code

See all my projects →