Cómo ejecutar una sola prueba en nightwatch
¿Cómo corro solo Test 3
desde las siguientes pruebas?
module.exports = {
'Test 1':function(){},
'Test 2':function(){}
'Test 3':function(){}
}
5 answers
Se ha añadido un nuevo parámetro test testcase para ejecutar un testcase especificado.
nightwatch.js --test tests\demo.js --testcase "Test 1"
Es una característica nueva desde la v0.6.0
Https://github.com/beatfactor/nightwatch/releases/tag/v0.6.0
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-17 14:48:46
Debe usar etiquetas específicas antes de function y separar todas las funciones en diferentes archivos bajo el directorio tests, y luego llamar al comando con el argumento tag tag. Ver página de etiquetas wiki nightwatch y ver este ejemplo:
// --- file1.js ---
module.exports = {
tags: ['login'],
'Test 1':function(){
//TODO test 1
}
};
// --- file2.js ---
module.exports = {
tags: ['special', 'createUser'],
'Test 2':function(){
//TODO test 2
},
};
// --- file3.js ---
module.exports = {
tags: ['logoff', 'special'],
'Test 3':function(){
//TODO test 3
},
}
Si ejecuta:
nightwatch.js --tag login
Solo ejecuta Prueba 1 , sin embargo si ejecuta:
nightwatch.js --tag special
Se ejecutarán las pruebas 2 y 3.
Puede especificar más de una etiqueta
nightwatch.js --tag tag1 --tag tag2
Separar cada función de prueba es obligatoria porque Nightwatch se maneja con filematcher cada archivo. Ver código Github.
PD: Si el archivo tiene errores de sintaxis, es posible que la prueba no se ejecute o no se haya encontrado la prueba
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-24 16:53:30
El indicador test testcase puede usarse desde la versión 0.6 para ejecutar una única prueba desde la línea de comandos, por ejemplo,
nightwatch.js --test tests\demo.js --testcase "Test 1"
Esto podría realizarse mediante grupos de prueba o etiquetas de prueba. También puede ejecutar una sola prueba con el indicador --test
, por ejemplo,
nightwatch.js --test tests\demo.js
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-20 14:22:37
Puedes hacer algo como:
node nightwatch.js -e chrome --test tests/login_test --testcase tc_001
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-08-10 21:36:15
Otra forma posible de hacerlo, sería usar lo siguiente en cada caso de prueba que desee omitir:
'@disabled': true,
Esto simplemente se puede establecer en false o eliminar si desea probarlo.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-21 16:15:36