将AVA与PhantomJS结合使用
我试图使用AVA和PhantomJS(实际上是PhantomJS节点)在网页上运行一些测试 我必须下载文件,第一个是一个模块,使用Phantom(load page.js)加载网页 第二个是测试:将AVA与PhantomJS结合使用,phantomjs,ava,Phantomjs,Ava,我试图使用AVA和PhantomJS(实际上是PhantomJS节点)在网页上运行一些测试 我必须下载文件,第一个是一个模块,使用Phantom(load page.js)加载网页 第二个是测试: import test from 'ava'; import loadPage from '../helpers/load-page'; test('prueba', async t => { const check = count => {
import test from 'ava';
import loadPage from '../helpers/load-page';
test('prueba', async t => {
const check = count => {
t.is(count.childNodes.length, 9);
}
await loadPage('http://webslides.tv', () => {
const ws = document.querySelector('#webslides');
return ws;
}, async (count) => {
await check(count);
});
});
加载页面后是否可以运行测试?我想用同一个页面运行几个测试,但我不想每次都加载页面
谢谢您需要更改您的助手,使其不评估任何内容。然后可以重用页面实例:
从“ava”导入测试;
从“../helpers/load page”导入loadPage;
让页面;
test.before(异步t=>{
页面=等待加载页面('http://webslides.tv');
});
测试('prueba',异步t=>{
常量计数=等待页面。评估(()=>{
const ws=document.querySelector(“#webslides”);
返回ws;
});
t、 是(count.childNodes.length,9);
});
您需要更改助手,使其不评估任何内容。然后可以重用页面实例:
从“ava”导入测试;
从“../helpers/load page”导入loadPage;
让页面;
test.before(异步t=>{
页面=等待加载页面('http://webslides.tv');
});
测试('prueba',异步t=>{
常量计数=等待页面。评估(()=>{
const ws=document.querySelector(“#webslides”);
返回ws;
});
t、 是(count.childNodes.length,9);
});
import test from 'ava';
import loadPage from '../helpers/load-page';
test('prueba', async t => {
const check = count => {
t.is(count.childNodes.length, 9);
}
await loadPage('http://webslides.tv', () => {
const ws = document.querySelector('#webslides');
return ws;
}, async (count) => {
await check(count);
});
});