Added config file as described ".testcaferc.json" inside the root folder where i execute tests.
Config file is simple, only browsers is declared.
When executing tests, Error occurs with: No Browser selected to test agains.
So, i thought, lets try video recording.
The following message is displayed when running tests.
First: The "browsers" option from the configuration file will be ignored.
Second: Error: Cannot find module '.testcaferc.json'
What's causing this behavior?
Thank you for your report. I've reproduced the problem with the No Browser selected to test against. and our team is working on the fix.
As a workaround, you can specify both browsers and source files in a configuration file.
However, I can't reproduce the problem with the Cannot find module '.testcaferc.json' error. Could you please provide the following information:
.testcaferc.json configuration fileGreat, thanks! And ofcourse.
My folder structure:
react-project
I've used many:
.testcaferc.json configuration file{
"browsers": "chrome",
"reporter": [
{
"name": "json",
"output": "reports/report.json"
}
]
}
All files look pretty much like this
import * as u from '../../src/utilities/functions';
import * as s from '../../src/utilities/selectors';
fixture`Package: Test Suite`
.page('http://localhost:5000')
.beforeEach( async t => {
await t.resizeWindow(1024,690).setTestSpeed(1)})
test('Test name', async (t) => {
await t.click(s.btnQca)
await t.click(s.btnAnalysis);
await u.selectFrame(29);
await t.click(s.drawButton);
await u.clickPoint(332,104);
await u.clickPoint(320,125);
await u.clickPoint(298,150);
await u.doubleClickPoint(298,150);
//ASSERT
await u.objectDoesNotExist(s.viewportSvg);
});
md5-6340c7bb46d3890f3bd511dea00f209d
export const clickPoint = (x: number, y: number) => {
return t.click(s.canvas, { offsetX : x, offsetY: y });
};
export const doubleClickPoint = (x: number, y: number) => {
return t.doubleClick(s.canvas, { offsetX : x, offsetY: y });
};
export const objectDoesExist = async (object: any) => {
const result = await object.exists ? true : false
await t.expect(result).ok("Object does not exist");
};
export const selectFrame = async (targetFrame: number) => {
const frametext = s.currentFrame.textContent;
const returnValue = await frametext;
const afterSlash = returnValue.lastIndexOf('/');
const numberOfFrames: any = returnValue.substring(afterSlash + 1);
const correction = 4;
const track = s.sliderTrack;
const sliderWidth = await t.eval(() => track().clientWidth, {
dependencies: { track }
});
//Calculates X coordinates to be able to select frames
await t.doubleClick(track, {offsetX: Math.round(sliderWidth / numberOfFrames * targetFrame) - correction});
};
Unfortunately I can't reproduce the second problem with your data. Could you please try to reproduce the "Cannot find module '.testcaferc.json'" error with the following .testcaferc.json file and provide TestCafe command arguments and terminal output:
{
"browsers": "chrome",
"reporter": [
{ "name": "spec" },
{
"name": "json",
"output": "reports/report.json"
}
]
}
The following error occurs when adding your config data:
PS C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1> yarn testcafe chrome test/test-cases/autorun --video artifacts/videos/
yarn run v1.13.0
$ "C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1node_modules.bin\testcafe" chrome test/test-cases/autorun --video artifacts/videos/
ERROR Cannot prepare tests due to an error.
Error: Cannot find module '.testcaferc.json'
at Object.
at Function._compile [as _execAsModule] (C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1node_modules\testcafe\src\compiler\test-file\api-based.js:50:13)
at TypeScriptTestFileCompiler._execAsModule [as compile] (C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1node_modules\testcafe\src\compiler\test-file\api-based.js:144:42)
at compile (C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1node_modules\testcafe\src\compiler\index.js:48:42)
at step (C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
at C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1node_modules\babel-runtime\helpers\asyncToGenerator.js:28:13
Type "testcafe -h" for help.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Could you please share the analyze-view.ts file which caused the error? It is located in the following directory judging by the stack trace:
C:\Users\user\Documents..(project name)..\Test environment\TestCafe builds\test_dir_v1\test\test-cases\autorun\
Â
I guess you have something like require('.testcaferc.json') in line 4 in this file. If it is so, you can fix this statement in the following way: require('./.testcaferc.json').
The minor adjustment fixed something, i am able to run the tests now.
A funny thing is that when i run the command with "chrome", the video's record. But the resize event does not take place. It looks like the before each event does not trigger.
But when i remove "chrome", i get the error:
ERROR Unable to find the browser. "test/test-cases/autorun" is not a browser alias or path to an executable file.
Here is the code:
import * as u from '../../src/utilities/functions';
import * as s from '../../src/utilities/selectors';
import * as i from '../../src/utilities/init';
require('./.testcaferc.json');
fixture`Package: Analysis View (vessel analysis)`
.page('http://localhost:5000')
.beforeEach( async t => {
await t.resizeWindow(1024,690).setTestSpeed(1)})
test('TC-QW-QXA-001 - Entering Vessel Analysis View', async (t) => {
//SETUP & ACTION
//await t.click(s.btnAnalysis);
console.log(' ↓ Disabled because of bug');
//ASSERT
//await t.expect(s.btnAnalysis.hasClass('selected')).ok();
});
test('TC-QW-QXA-002 - Defining a vessel', async (t) => {
//SETUP & ACTION
await i.Qva5ClicksFrame23();
//ASSERT
await u.objectDoesExist(s.viewportSvg);
});
test('TC-QW-QXA-003 - Discard define or edit action', async (t) => {
//NOTE
console.log(' ↓ Edit action can not be tested yet');
//SETUP
await t.click(s.btnQca)
await t.click(s.btnAnalysis);
await u.selectFrame(29);
await t.click(s.drawButton);
await u.clickPoint(332,104);
await u.clickPoint(320,125);
await u.clickPoint(298,150);
//ACTION
await t.pressKey('esc');
//ASSERT
await u.objectDoesNotExist(s.viewportSvg);
});
test('TC-QW-QXA-004 - Delete contour', async (t) => {
//SETUP
await i.Qva5ClicksFrame23();
//ACTION
await t.click(s.deleteContour);
//ASSERT
await u.objectDoesNotExist(s.viewportSvg);
});
test.skip('TC-QW-QXA-005 - Edit contour', async (t) => {
console.log(' ↓ TC-QW-QXA-005 editing is not possible yet')
});
test.skip('TC-QW-QXA-006 - Add analysis method', async (t) => {
console.log(' ↓ TC-QW-QXA-006 editing is not possible yet')
});
test.skip('TC-QW-QXA-007 - Remove analysis method', async (t) => {
console.log(' ↓ TC-QW-QXA-007 editing is not possible yet')
});
test.skip('TC-QW-QXA-008 - Reposition marker', async (t) => {
console.log(' ↓ TC-QW-QXA-008 editing is not possible yet')
});
test.skip('TC-QW-QXA-010 - Switch analysis method', async (t) => {
console.log(' ↓ TC-QW-QXA-010 editing is not possible yet')
});
test.skip('TC-QW-QXA-020 - Analysis results', async (t) => {
console.log(' ↓ TC-QW-QXA-020 editing is not possible yet')
});
Closed by #3427.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.