How to catch NestJS redis retry strategy error - redis

I've created a NestJS redis cache module with a retry strategy.
#Module({
imports: [
CacheModule.registerAsync<RedisClientOptions>({
isGlobal: true,
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
store: redisStore,
host: configService.get<string>('redis.host'),
port: configService.get<number>('redis.port'),
password: configService.get<string>('redis.password'),
tls: configService.get<boolean>('redis.tls'),
retry_strategy: (options) => {
console.log({ options });
if (options.attempt > 2) {
// throw new Error('Retry attemps exhausted');
return undefined;
}
return Math.min(options.attempt * 100, 3000);
},
}),
inject: [ConfigService],
}),
],
controllers: [],
providers: [],
})
export class RedisCacheModule {}
I have also configured the AppModule to catch redis connection errors so that these can be handled gracefully not resulting in a fatal error. The caching implementation is not critical to the applications functionality.
export class AppModule {
constructor(#Inject(CACHE_MANAGER) cacheManager) {
const client = cacheManager.store.getClient();
client.on('error', (error) => {
console.log('Redis error');
console.log(error);
});
}
}
The issue I am experiencing is that when the third and final reconnection attempt fails, it causes a fatal error and the application crashes. Is there a way to catch these errors also?
Example logs:
[service] Redis error
[service] Error: getaddrinfo ENOTFOUND redis-master.redis.svc.cluster.local
[service] at GetAddrInfoReqWrap.onlookup {
[service] errno: -3008,
[service] code: 'ENOTFOUND',
[service] syscall: 'getaddrinfo',
[service] hostname: 'redis-master.redis.svc.cluster.local'
[service] }
[service] {
[service] options: {
[service] attempt: 3,
[service] error: Error: getaddrinfo ENOTFOUND redis-master.redis.svc.cluster.local
[service] at GetAddrInfoReqWrap.onlookup {
[service] errno: -3008,
[service] code: 'ENOTFOUND',
[service] syscall: 'getaddrinfo',
[service] hostname: 'redis-master.redis.svc.cluster.local'
[service] },
[service] total_retry_time: 300,
[service] times_connected: 0
[service] }
[service] }
[service] /app/node_modules/nestjs-cache-module/lib/cache-module.js
[service] throw new Error('Retry attemps exhausted');
[service] ^
[service]
[service] Error: Retry attemps exhausted
[service] at Object.retryStrategy [as retry_strategy] (/app/node_modules/nestjs-cache-module/lib/cache-module.js)
[service] at RedisClient.connection_gone (/app/node_modules/redis/index.js:554:41)
[service] at RedisClient.on_error (/app/node_modules/redis/index.js:346:10)
[service] at Socket.<anonymous> (/app/node_modules/redis/index.js:223:14)
[service] at Socket.emit (node:events:513:28)
[service] at emitErrorNT (node:internal/streams/destroy:151:8)
[service] at emitErrorCloseNT (node:internal/streams/destroy:116:3)
[service] at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Related

Cannot connect NestJS Bull to Elasticache (Redis)

I stuck when connecting NestJS Bull to AWS Elasticache on deployment
On local I easily connect to Redis by
import { Module } from '#nestjs/common';
import { BullModule } from '#nestjs/bull';
#Module({
imports: [
BullModule.forRoot({
redis: {
host: 'localhost',
port: 6379,
password: 'secret',
},
}),
],
})
export class AppModule {}
I even try on https://app.redislabs.com/ a official Redis cloud. It still working.
But on deployment with Elasticache. There is no error on startup but the queue is not worked as expected
My code last year was worked, But now no response
import Redis from 'ioredis';
#Module({
imports: [
BullModule.forRoot({
createClient: () => {
return config.get('redis.cluster.host')
? new Redis.Cluster([
{
port: +config.get('redis.cluster.port'),
host: config.get('redis.cluster.host'),
},
])
: new Redis(+config.get('redis.standalone.port'), config.get('redis.standalone.host'));
},
}),
FeeQueue,
],
providers: [],
exports: [],
})
export class QueuesModule {}
Could you have time to help me. Thanks
I don't know if it'll be the same for you, but I just ran into a similar issue. The queue wasn't working, but no error logged. After a lot of testing, I finally got it to log an error saying that enableReadyCheck and maxRetriesPerRequest can't be used for bclients and subscibers. So I unset them:
BullModule.forRoot({
createClient: (type) => {
const opts =
type !== 'client'
? { enableReadyCheck: false, maxRetriesPerRequest: null }
: {}
return config.get('redis.cluster.host')
? new Redis.Cluster([{ host, port }], opts)
: new Redis({ host, port, ...opts});
},
})

Cypress throwing SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (17:0)

I am trying to use cypress select tests but facing the following exception. Did anyone face this issue before?
cypress/plugins/index.ts
const TC_GROUPING = require('cypress-select-tests/grep')
module.exports = (on, config) => {
require('cypress-terminal-report/src/installLogsPrinter')(on, {
printLogsToConsole: 'always'
}
)
on('file:preprocessor', TC_GROUPING(config))
on('task', {
// Returns the customer Object of type: Customer
createCustomer: () => {
console.log("This is Sample Function")
}
})
return config
}
Error Message:
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (17:0)
at Parser.pp$4.raise (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/acorn/dist/acorn.js:2927:15)
at Parser.pp$1.parseStatement (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/acorn/dist/acorn.js:870:18)
at Parser.pp$1.parseTopLevel (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/acorn/dist/acorn.js:755:23)
at Parser.parse (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/acorn/dist/acorn.js:555:17)
at Function.parse (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/acorn/dist/acorn.js:578:37)
at Object.parse (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/acorn/dist/acorn.js:5143:19)
at module.exports (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/falafel/index.js:23:22)
at Object.findTests (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/cypress-select-tests/src/spec-parser.js:95:3)
at process (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/cypress-select-tests/src/itify.js:18:33)
at Stream.onend (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/cypress-select-tests/src/itify.js:52:18)
at _end (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/through/index.js:65:9)
at Stream.stream.end (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/through/index.js:74:5)
at DestroyableTransform.onend (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:577:10)
at Object.onceWrapper (events.js:416:28)
at DestroyableTransform.emit (events.js:322:22)
at endReadableNT (/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`/Users/saahithg/workspace/ElmoCypressFinal/src/ElmoCypress/cypress/plugins/index.ts`)
at Object.get (/private/tmp/cypress_cache/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:968:15)
at EventEmitter.handleError (/private/tmp/cypress_cache/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/index.js:159:20)
at EventEmitter.emit (events.js:310:20)
at ChildProcess.<anonymous> (/private/tmp/cypress_cache/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
at ChildProcess.emit (events.js:310:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
Added the following lines in plugins/index.ts as mentioned in blog: https://en.it1352.com/article/1963119.html but no luck. Did anyone encounter this issue?
const options = {
// send in the options from your webpack.config.js, so it works the same
// as your app's code
webpackOptions: require('../../webpack.config'),
watchOptions: {}
}
on('file:preprocessor', web_pack(options))
webpack.config.js
const path = require('path');
module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};

JSDOM - ECONNREFUSED 127.0.0.1:80 when running test in Azure DevOps

When the job is running on Azure DevOps yarn test:unit the following error happens multiple times. This does not prevent tests to pass. The project runs vue and jest for testing. When runs locally, no errors occur.
jest.config.js
const Vue = require('vue');
const Vuetify = require('vuetify');
Vue.use(Vuetify);
module.exports = {
preset: '#vue/cli-plugin-unit-jest/presets/typescript-and-babel',
collectCoverage: false,
collectCoverageFrom: [
'src/**/*.{js,vue}',
'!src/registerServiceWorker.js',
'!src/helpers.js',
'!src/constants/**',
'!src/mixins/**',
'!src/plugins/**',
'!src/router/**',
'!src/test/**',
'!src/main.js', // No need to cover bootstrap file
],
transform: {
'vee-validate/dist/rules': 'babel-jest',
},
transformIgnorePatterns: [
'<roodDir>/node_modules/(?!vee-validate/dist/rules)',
],
testEnvironmentOptions: {
// Allow test environment to fire onload event
// See https://github.com/jsdom/jsdom/issues/1816#issuecomment-355188615
resources: 'usable',
},
};
axios.js
let baseURL = '';
switch (process.env.NODE_ENV) {
case 'development': {
baseURL = 'https://localhost:44359/api/v1';
break;
}
case 'production': {
baseURL = 'webapi/api/v1';
break;
}
case 'docker': {
const port = process.env.VUE_APP_WebAPI_PORT;
const path = process.env.VUE_APP_WebAPI_Path;
const version = process.env.VUE_APP_WebAPI_Version;
const url = new URL(window.location.origin);
url.port = port;
baseURL = `${url.origin.toString()}/${path}/${version}`;
break;
}
default: baseURL = 'webapi/api/v1';
}
/* eslint-disable import/prefer-default-export */
export const http = axios.create({
baseURL,
withCredentials: true,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
paramsSerializer: (params) => {
Object.keys(params).forEach((key) => {
if (_isArray(params[key]) && !params[key].length) {
delete params[key];
}
});
return qs.stringify(params, { arrayFormat: 'repeat' });
},
});
Error
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (/home/vsts/work/1/s/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:54:19)
at Request. (/home/vsts/work/1/s/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:675:20)
at Request.emit (events.js:327:22)
at Request.onRequestError (/home/vsts/work/1/s/node_modules/request/request.js:877:8)
at ClientRequest.emit (events.js:315:20)
at Socket.socketErrorListener (_http_client.js:426:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) undefined
console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Any help would be welcome
This error could be due to i18n usage. I have noticed that when I have the same problem and debug it, it gets this error because it cannot access localization files. You can use the moduleNameMapper setting as a solution.
https://jestjs.io/docs/en/configuration#modulenamemapper-objectstring-string--arraystring

Running "npm run webpack"I get a "TypeError: CleanWebpackPlugin is not a constructor"

I am running asp.net core 2.2 with Aurelia front end - a SPA.
I have had this running in core 3.0 however I had to derate to run OData (they havent put it into that version yet).
I have opened a CMD and typed npm run webpack:watch and fails so I looked up the first line of the error in SO and got this, but alas this is not a syntax issue - I have the right syntax.
(webpack is installed and its version is 4.38.0)
The error in detail:
TypeError: CleanWebpackPlugin is not a constructor
at module.exports (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\webpack.config.js:73:4)
at handleFunction (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\utils\prepareOptions.js:21:13)
at prepareOptions (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\utils\prepareOptions.js:9:5)
at requireConfig (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\utils\convert-argv.js:119:14)
at C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\utils\convert-argv.js:125:17
at Array.forEach (<anonymous>)
at module.exports (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\utils\convert-argv.js:123:15)
at C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\cli.js:71:45
at Object.parse (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\node_modules\yargs\yargs.js:567:18)
at C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\cli.js:49:8
at Object.<anonymous> (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack-cli\bin\cli.js:365:3)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (C:\AURELIA\5 - ODATA\OLD\JobsLedger.API\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Jobsledger.API#0.0.0 webpack:watch: `webpack --mode development --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Jobsledger.API#0.0.0 webpack:watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\simon\AppData\Roaming\npm-cache\_logs\2019-07-30T07_45_40_798Z-debug.log
This has to do with my webpack file in that its complaining about CleanWebPackPlugin is not a constructor however after checking the syntax is correct it has to be something else..
Here, for completeness, is the webpack.config.js file:
const path = require("path");
const webpack = require("webpack");
const { AureliaPlugin, ModuleDependenciesPlugin, GlobDependenciesPlugin } = require("aurelia-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const bundleOutputDir = "./wwwroot/dist";
module.exports = (env, argv) => {
if ((!argv || !argv.mode) && process.env.ASPNETCORE_ENVIRONMENT === "Development") {
argv = { mode: "development" };
}
console.log("mode =", argv.mode);
const isDevBuild = argv.mode !== "production";
const cssLoaders = ["css-loader", "postcss-loader"];
const scssLoaders = [...cssLoaders, "sass-loader"];
return [{
target: "web",
mode: isDevBuild ? "development" : "production",
entry: { "app": ["es6-promise/auto", "aurelia-bootstrapper"] },
resolve: {
extensions: [".ts", ".js"],
modules: ["ClientApp", "node_modules"]
},
output: {
path: path.resolve(bundleOutputDir),
// Asp.Net JavaScriptServices does not tolerate "/" in public path, see https://github.com/aspnet/JavaScriptServices/issues/1495
publicPath: "dist/",
filename: "[name].[hash].js",
chunkFilename: "[name].[chunkhash].js",
pathinfo: false
},
module: {
rules: [
{ test: /\.(woff|woff2|png|eot|ttf|svg)(\?|$)/, use: { loader: "url-loader", options: { limit: 1, publicPath: "./" } } },
{ test: /\.ts$/i, include: [/ClientApp/], loader: "ts-loader" },
{ test: /\.html$/i, use: "html-loader" },
{ test: /\.css$/i, /*include: [/node_modules/],*/ issuer: /\.html$/i, use: cssLoaders },
{ test: /\.css$/i, /*include: [/node_modules/],*/ exclude: [/bootstrap.css$/, /font-awesome.css$/], issuer: [{ not: [{ test: /\.html$/i }] }], use: ["style-loader", ...cssLoaders] },
{ test: /\.css$/, include: [/bootstrap.css$/, /font-awesome.css$/], use: [{ loader: MiniCssExtractPlugin.loader }, ...cssLoaders] },
{ test: /\.scss$/i, issuer: /(\.html|empty-entry\.js)$/i, use: scssLoaders },
{ test: /\.scss$/i, issuer: /\.ts$/i, use: ["style-loader", ...scssLoaders] }
]
},
optimization: {
splitChunks: {
chunks: "all",
// comment the following to avoid creatin a separate bundle for each npm module
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
// npm package names are URL-safe, but some servers don't like # symbols
return `npm.${packageName.replace('#', '')}`;
}
}
}
}
},
devtool: isDevBuild ? "source-map" : false,
performance: {
hints: false
},
plugins: [
new CleanWebpackPlugin(),
new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery" }),
new HtmlWebpackPlugin({ template: 'index.ejs', filename: "../../wwwroot/index.html", inject: false, metadata: {}, alwaysWriteToDisk: true }),
new AureliaPlugin({ aureliaApp: "boot" }),
new GlobDependenciesPlugin({ "boot": ["ClientApp/**/*.{ts,html}"] }),
new ModuleDependenciesPlugin({}),
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[name].[chunkhash].css"
})
],
devServer: {
contentBase: "wwwroot/",
compress: true,
writeToDisk: true,
hot: false
}
}];
};
Any ideas?
Try changing to
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

this.props.children.map is not a function when testing react component with enzyme

I have a React component which also makes use of its children using this.props.children:
import classnames from 'classnames';
import React from 'react';
export default function Toolbar(props) {
return <ul className="sulu-Toolbar">{props.children}</ul>;
}
Toolbar.Item = class extends React.Component {
constructor(props) {
super(props);
this.state = {
open : false
};
}
static propTypes = {
title: React.PropTypes.string,
isChild: React.PropTypes.bool
};
static defaultProps = {
title: '',
isChild: false
};
render() {
var classNames = classnames({
'sulu-Toolbar-Item': !this.props.isChild,
'sulu-Toolbar-Item-Dropdown-Item': this.props.isChild
});
return <li className={classNames} onClick={this.onClick}>
{this.props.title} {this.props.children ? <span className="sulu-Toolbar-Item-Arrow"/> : ''}
{!!this.props.children ? this.getChildren() : ''}
</li>;
}
getChildren = () => {
var children = null;
if (!!this.state.open) {
children = <ul className="sulu-Toolbar-Item-Dropdown">
{
this.props.children.map((child) => {
return <Toolbar.Item {...child.props} key={child.key} isChild={true}/>;
})
}
</ul>;
}
return children;
};
onClick = () => {
!!this.props.children ? this.toggleOpen() : this.props.onClick();
};
toggleOpen = () => {
this.setState({open: !this.state.open});
};
};
This works great so far in a browser, but when I want to test it using enzyme I get a strange error. This is the test:
import {mount, shallow} from 'enzyme';
import React from 'react';
import test from 'tape';
import Toolbar from '../src/toolbar';
import './setup.js';
test('Toolbar item should open and close', (t) => {
const toolbarItem = mount(<Toolbar.Item><Toolbar.Item/></Toolbar.Item>);
t.test('Toolbar item should open', (t) => {
t.plan(1);
toolbarItem.find('li').simulate('click');
t.equals(toolbarItem.find('p').length, 1);
});
t.test('Toolbar item should close', (t) => {
t.plan(1);
toolbarItem.find('li').simulate('click');
t.equals(toolbarItem.find('p').length, 0);
});
});
test('Toolbar item should execute onclick handler', (t) => {
t.plan(1);
const toolbarItem = shallow(<Toolbar.Item onClick={() => {t.ok(true)}}/>);
toolbarItem.find('li').simulate('click');
});
test ('Toolbar item should show title', (t) => {
t.plan(1);
const toolbarItem = shallow(<Toolbar.Item title="Test"/>);
t.ok(toolbarItem.contains('Test'));
});
When I want to execute that test I get the following error message:
> # test /Users/daniel/Development/personal/react-playground
> tape -r ./test/babel-register-setup test/*-test.js
TAP version 13
# Toolbar item should open and close
# Toolbar item should open
/Users/daniel/Development/personal/react-playground/src/toolbar.js:54
_this.props.children.map(function (child) {
^
TypeError: _this.props.children.map is not a function
at _class._this.getChildren (toolbar.js:45:41)
at _class.render (toolbar.js:35:43)
at ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactCompositeComponent.js:785:34)
at ReactCompositeComponentMixin._renderValidatedComponent (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactCompositeComponent.js:811:32)
at ReactCompositeComponentMixin._updateRenderedComponent (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactCompositeComponent.js:735:36)
at ReactCompositeComponentMixin._performComponentUpdate (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactCompositeComponent.js:715:10)
at ReactCompositeComponentMixin.updateComponent (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactCompositeComponent.js:634:12)
at ReactCompositeComponentMixin.performUpdateIfNecessary (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactCompositeComponent.js:548:12)
at Object.ReactReconciler.performUpdateIfNecessary (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactReconciler.js:165:22)
at runBatchedUpdates (/Users/daniel/Development/personal/react-playground/node_modules/react/lib/ReactUpdates.js:151:21)
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "run" "test"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! # test: `tape -r ./test/babel-register-setup test/*-test.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # test script 'tape -r ./test/babel-register-setup test/*-test.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tape -r ./test/babel-register-setup test/*-test.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/daniel/Development/personal/react-playground/npm-debug.log
I have tried to do that with mount and shallow, although I would prefer shallow of course. But both functions don't work as I expect. For mount I am also using jsdom, with the following setup.js script which is included in the test:
import jsdom from 'jsdom';
if (typeof document === 'undefined') {
global.document = jsdom.jsdom('<html><body></body></html>');
global.window = document.defaultView;
global.navigator = window.navigator;
}
And ideas what I am doing wrong?
UPDATE:
When I am adding a console.log(this.props.children) to the code I get the following structure in the test:
{ '$$typeof': Symbol(react.element),
type:
{ [Function: _class]
propTypes: { title: [Object], isChild: [Object] },
defaultProps: { title: '', isChild: false } },
key: null,
ref: null,
props: { title: '', isChild: false },
_owner: null,
_store: {} }