How to reuse test file in detox - react-native

I have an app where I am signing in and doing stuff. I want to reuse my signIn.e2e.js file. Basically I want to test dashboard, so I want to log in before that. Hence I want to use my signIn.e2e.js file in homeScreen.e2e.js file.
Any idea how I can do that?
I tried to do some research but haven't found anything. I am using jest test runner, it does have jest-runner-groups, but that's for jest, not for Detox.

Related

jest error: const warnedKeys: {[string]: boolean} = {};

If I run yarn test, which runs jest, I get the following error:
C:\react-native-project\node_modules\react-native\Libraries\Utilities\warnOnce.js:15
const warnedKeys: {[string]: boolean} = {};
But that only happens if I follow the directions of the react-native-testing-library:
Then automatically to add it to your jest tests by using setupFilesAfterEnv option in the
jest.config.js file:
If I remove the file I will not get that error and I can get simple tests to run. When I remove the file, the test runs but AsyncStorage is not recognized so the tests still don't run. I have AsyncStorage. It's installed and the app works, but I want to add component tests. I also noticed the file, jest.config.js, is conspicuously missing from the testing project itself. Is there any documentation or working example? I would rather not do a diff of my project and the testing project. Is there a more well-documented or reliable testing framework/module available?
I'm able to get working tests by following the documentation of the React Native Testing Library with the npm package name of #testing-library/react-native not to be confused with the React Native Testing Library with the npm package name of react-native-testing-library. Both packages allow testing components and are recommended by React-Native documentation but this one works when following the instructions. It also has instructions "to define a custom render method that includes things like global context providers, data stores, etc" so that testing components with AsyncStorage and such shouldn't be a problem.

Detox by.id is not a function

I'm working on my first test using detox but got the following problem:
Please help me.
Unfortunately, being a wrapper over common JS test-runners such as Mocha and Jest, when Detox fails to initialize in (i.e. in the beforeAll()) it is forced to move forward to nevertheless try to run all tests in the suite. Also, without proper initializaion, global objects such as by, device and even detox do net get registered. Hence the error.
What matters in your case is for you to scroll and find the first error provided by Detox' logs. That should give you a hint of what really went wrong.
In any case, your tests will not run without proper initialization, and the inclusion of init code in the path for the test runner. Be sure to thoroughly go over the setup guide and its references.

What do we specify in "mainWindowUrl" property in .testcafe-electron-rc for executable electron apps like atom/vscode?

I was looking at https://github.com/DevExpress/testcafe-browser-provider-electron repository.
To automate electron apps using testcafe, I see we need to provide "mainWindowUrl" in .testcafe-electron-rc . Regular electron apps have index.html files in it which I can pass to mainWindowUrl but I'm not sure what should we pass for executable electron apps like atom.exe/vscode.exe.
TestCafe will show a list of URLs opened during the app initialization time if it fails to find the main window URL. You can specify an empty string as a value of mainWindowUrl, wait until TestCafe shows an error and use links from the displayed list.
To test executable electron applications you should configure the 'testcafe-browser-provider-plugin' in another way. See the Testing an Executable Electron Application section for more information.

Meteor test only runs one test suite

This is part of my project directory.
Unfortunately, for some strange reasons, all but one tests are executed, the one contained in the file methods.transformations.test.js.
Everything seemed fine this morning, then I ran into some issues and fixed them, and when I looked back at the test results, all my tests are no longer executed. All the files are loaded, and if I put a console.log inside every describe, I see things being echo'ed, but no it(...) is executed.
I'm not sure what kind of information I can provide to help resolve this issue. Can someone help?
I'm using
practicalmeteor:chai#2.1.0_1
practicalmeteor:mocha#2.4.5_6
practicalmeteor:mocha-core#1.0.1
Edit
I just created a file /test/foo.test.js with this content :
describe('Testing', function () {
console.log("Testing...");
it('should test', function () {
console.log("This should be echoed");
});
});
And only "Testing" is echoed. Whereas the exact same code is put inside methods.transformations.test.js and everything is executed.
Edit 2
Yes, the Meteor Testing docs say that
The Meteor build tool and the meteor test command ignore any files located in any tests/ directory.
But my directory is only called test, not tests. Despite this, I went on and created a file called items.specs.js
However, the test case (i.e. the it(...)) is not executed.
I run my tests using npm test defined in my package.json as
...
"test": "meteor test --driver-package practicalmeteor:mocha --port 3100"
...
While editing this question with more data, I found my issue. If anyone encounter this... well... images are worth a thousand words. This might be your problem, too!

AngularJS : e2e tests with Karma Scenario Test Runner using cached source?

I am trying to set up some AngularJS e2e tests with Karma Scenario Test Runner. I did some modifications to the source files, but Karma doesn't seem to use these latest versions when testing.
In the source files, I added ids to some elements. Karma still couldn't find them, so I added a pause in the e2e test, so that I can mark and "Inspect elements" (using Chrome) on the current page in the test runner. The source code seems correct, except the latest changes are missing, i e, the ids aren't there. So what's happening here? Do I need to explicitly tell Karma the files have been updated somehow?
You can fix this issue by forcing angularjs to clear the application cache:
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
In Chrome developer tools settings, check "Disable cache (while DevTools is open)".
Obviously, this is a much more general issue than Angular's e2e test runner, but I decided to leave it here for now, in case somebody else has the same question.