Shows how to run tests using TestCafe on OpenFin.
- Clone this repo
- Install npm-modules:
npm install
- Run the tests:
npm start
We make use of the remote browser option in TestCafe to create a URL that would then be launched in OpenFin.
First we initialize the test runner:
testcafe = await createTestCafe('localhost', 1337, 1338);
runner = testcafe.createRunner();
const remoteConnection = await testcafe.createBrowserConnection();
This returns a remote connection object that contains the URL we will use to launch OpenFin.
Using the Node.js Adapter we can connect to a runtime and launch an OpenFin app using the URL returned by the remote connection.
// Connect to a runtime
const fin = await connect({
uuid: 'openfin-runtime-connection',
runtime: {
version: 'stable'
},
nonPersistent: true
});
fin.once('disconnected', process.exit);
// Create and run OpenFin application using test URL
const testApp = await fin.Application.create({
uuid: 'testcafe',
name: 'testcafe',
url: remoteConnection.url,
autoShow: true,
defaultHeight: 800,
defaultWidth: 1200,
saveWindowState: false
});
testApp.run();
Once the connection is ready, we let the test runner know that we want to run the tests. Once the tests run we close the test runner and the OpenFin app.
remoteConnection.once('ready', async () => {
await runner.src('tests.js');
await runner.browsers(remoteConnection);
await runner.run();
testcafe.close();
testApp.terminate();
});