mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-20 22:35:09 +00:00
add page.title() Nightmare action
This commit is contained in:
@@ -9,6 +9,12 @@ const fetch = require('node-fetch');
|
|||||||
run('production');
|
run('production');
|
||||||
run('development');
|
run('development');
|
||||||
|
|
||||||
|
Nightmare.action('page', {
|
||||||
|
title(done) {
|
||||||
|
this.evaluate_now(() => document.querySelector('h1').textContent, done);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function run(env) {
|
function run(env) {
|
||||||
describe(`env=${env}`, function () {
|
describe(`env=${env}`, function () {
|
||||||
this.timeout(20000);
|
this.timeout(20000);
|
||||||
@@ -142,26 +148,17 @@ function run(env) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('serves /', async () => {
|
it('serves /', async () => {
|
||||||
const title = await nightmare
|
const title = await nightmare.goto(base).page.title();
|
||||||
.goto(base)
|
|
||||||
.evaluate(() => document.querySelector('h1').textContent);
|
|
||||||
|
|
||||||
assert.equal(title, 'Great success!');
|
assert.equal(title, 'Great success!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('serves static route', async () => {
|
it('serves static route', async () => {
|
||||||
const title = await nightmare
|
const title = await nightmare.goto(`${base}/about`).page.title();
|
||||||
.goto(`${base}/about`)
|
|
||||||
.evaluate(() => document.querySelector('h1').textContent);
|
|
||||||
|
|
||||||
assert.equal(title, 'About this site');
|
assert.equal(title, 'About this site');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('serves dynamic route', async () => {
|
it('serves dynamic route', async () => {
|
||||||
const title = await nightmare
|
const title = await nightmare.goto(`${base}/blog/what-is-sapper`).page.title();
|
||||||
.goto(`${base}/blog/what-is-sapper`)
|
|
||||||
.evaluate(() => document.querySelector('h1').textContent);
|
|
||||||
|
|
||||||
assert.equal(title, 'What is Sapper?');
|
assert.equal(title, 'What is Sapper?');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -263,7 +260,7 @@ function run(env) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await nightmare.evaluate(() => document.querySelector('h1').textContent),
|
await nightmare.page.title(),
|
||||||
'About this site'
|
'About this site'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -277,7 +274,7 @@ function run(env) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await nightmare.evaluate(() => document.querySelector('h1').textContent),
|
await nightmare.page.title(),
|
||||||
'About this site'
|
'About this site'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user