-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.js
32 lines (25 loc) · 1018 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import JSONconfig from './config/config.json';
import JSconfig from './config/config';
import { ClientFunction } from 'testcafe';
import { pathToFileURL } from 'url';
import { resolve } from 'path';
const getDocumentUri = ClientFunction(() => document.documentURI);
const getFullFilePath = path => {
const resolvedPath = resolve(__dirname, path);
return pathToFileURL(resolvedPath).href;
};
fixture `Pass parameters to tests`;
//set an environment variable
process.env.url = './src/env.html';
test('Navigate to URL from an environment variable', async t => {
await t.expect(getDocumentUri()).eql(getFullFilePath(process.env.url));
})
.page(process.env.url);
test('Navigate to URL from .js configuration file', async t => {
await t.expect(getDocumentUri()).eql(getFullFilePath(JSconfig.url));
})
.page(JSconfig.url);
test('Navigate to URL from JSON configuration file', async t => {
await t.expect(getDocumentUri()).eql(getFullFilePath(JSONconfig.url));
})
.page(JSONconfig.url);