Increase the value of the "pageRequestTimeout" variable, enable the "retryTestPages" option - testing

I recently cloned, ran npm install and npm run test for a test Cafe project and I immediately got the following error:
Increase the value of the "pageRequestTimeout" variable, enable the "retryTestPages" option, or use quarantine mode to perform additional attempts to execute this test.
Error details:
Failed to find a DNS-record for the resource at "http://localhost:3000/".
Browser: Chrome 97.0.4692.71 / macOS 10.15.7
23 | async getLoginValidationIssue() {
24 | return Selector('[data-cy=failed-auth]')
25 | }
26 |
27 | async login(username, pwd) {
> 28 | await t.typeText('input[name=email]', username)
29 | await t.typeText('input[name=password]', pwd)
30 | await t.click(this.submitButton)
31 | return t;
32 | }
33 |
This is my first time trying to use test Cafe so I am unclear what is going on.

I suppose that your website doesn't run, and that's why it isn't available at the 3000 port by the "http://localhost:3000/" URL. Could you please check whether you can open the site at "http://localhost:3000/" in your browser before the execution of tests? The web resource tested by TestCafe must be available by the corresponding URL, in your case it is "http://localhost:3000/" .

Related

Jest failed tests no longer provide failure info, only `maxLength` error

In my project we had Jest running just fine and as far as I know no test dependencies were changed. When tests would fail it would log out the details of what was expected versus what was received. But if I have a failing test now (or try to make it fail like the following example) all I get is an error around pretty-format options:
when provided no parameters other than text › default values are set correctly
pretty-format: Unknown option "maxWidth".
48 |
49 | it('default values are set correctly', async () => {
> 50 | expect(element.variant).toBe('primarzy');
It should be telling me that it expected "primarzy" (misspelled on purpose) but got "primary". This is happening no matter which test suite has a failed test.
So for anyone else who encounters this, apparently different packages in my test dependencies were trying to run different versions of pretty-format breaking failed test output. The fix for me was just manually installing pretty-format:
npm i pretty-format --save-dev
Everything works fine after that.

Migrating from local GitLab to cloud based GitLab results in npm test failing: "TypeError: Cannot read property 'close' of undefined"

On our local build instance with GitLab running jest everything works fine. We are migrating everything to gitlab's cloud and running ci/cd there. The linter, build, etc. all work, but when it gets to npm test and tries to execute the tests, every one of them fails with the same error in same place:
FAIL tests/Charts.test.js
● Test suite failed to run
TypeError: Cannot read property 'close' of undefined
42 |
43 | afterAll(() => {
> 44 | browser.close();
| ^
45 | });
Feels like a dependency issue or configuration. Any help would be appreciated. LMK if something else is needed like package file.
We figured out the problem, turns out the xserver stuff wasn't installed and since we had headless set to false, the browser window couldn't open up.
Setting 'headless' to 'true' let us progress

React-native jest test giving unexpected token

Getting an unexpected token from the component class. Looking for advice on how I can proceed.
The failure:
● Test suite failed to run
C:/../react-native/jest/mockComponent.js: Unexpected token (20:23)
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
18 |
19 | const Component = class extends SuperClass {
> 20 | static displayName = 'Component';
| ^
21 |
22 | render() {
23 | const name =
This worked for me https://github.com/expo/expo/issues/2595#issuecomment-440966998
I think the problem was having jest and jest-expo installed
For me, this worked:
"transformIgnorePatterns": [
"/node_modules/(?!sentry|react-native).+\\.js$",
],
Notice that you must list there all your node_modules
/Users/guillermo/alibrate/alibrate-mobile/node_modules/react-native/jest/mockComponent.js:20
static displayName = 'Component';

React native pure js module with flow

I'm trying to publish my first react native pure js module which uses flow. I'm having a hard time.
My repo is here - https://github.com/Noitidart/react-native-buttonex
Source is in ./src/index.js. I use flow there. So I have done in my repo npm i flow-bin#0.57.3 --save-dev.
I then simply did a npm publish. Is there anything else I need to do?
It is not able to be used in Expo.
Doing:
import Button from 'react-native-buttonex' // ERROR. The Expo team has been notified.
Adds that "Error: expo team has been notified". And trying to run it shows red box with "Failed to download module".
I thought to stip the flowtypes so I added .babelrc with:
{
"presets": ["flow"]
}
But when I run babel I get error:
SyntaxError: src/index.js: Unexpected token (29:10)
27 |
28 | class Button extends Component<Props, State> {
> 29 | state = {
| ^
30 | activeAnim: new Animated.Value(0)
31 | }
It seems like its not liking the ES2017 stuff which is normal for react-native.
May you please guide m on how to properly publish this?

How to get rid of supertest's output when testing express applications?

I'm building an Express.js API and I'm using mocha and supertest for testing.
However, take a look at this:
root path
GET / 200 5.789 ms - 19
✓ returns 200 status code
GET / 200 0.787 ms - 19
✓ returns json mime type
GET / 200 0.382 ms - 19
✓ contains the package version
I want to get rid of the GET / 200 log so it can look like this:
root path
✓ returns 200 status code
✓ returns json mime type
✓ contains the package version
Any ideas?
[Solved] The output was generated from morgan logger.
The solution was to wrap the middleware like this:
if (app.get('env') === 'development') {
app.use(logger('dev'));
}