Skip to content

Instantly share code, notes, and snippets.

scripts for launch instance

# main.tf

variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "instance_type" {}

provider "aws" {
  access_key = var.aws_access_key

Sinon Stub method which invoke from method after click

export default class Class extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            typeOfNodes: 0,
            lifetimeInYears: 1,
        };

Error: The target '' could not be identified in the dom, tip: check spelling

in my case it was Popover from _reactstrap

in blabla.spec.js

import React from 'react';
import {shallow, mount} from 'enzyme';
import {expect} from 'chai';
import blabla from '../src/components/page_components/blabla';
import {Router} from "react-router";

enzyme setState example

we have ItemsList.js component with state

import React from 'react'

export default class ItemsList extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            loaded: false,

problem - the content does not appear until this.props.SOMETHING is not true or does not exists or else

we have a LogsList.js component

import React from 'react'
import {LinearProgress} from '@rmwc/linear-progress';

export default class LogsList extends React.Component {
    constructor(props) {
        super(props);
    }

enzyme, mocha, chai testing changes in STATE of component

we have LogsList.js component

import React from 'react'

export default class LogsList extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            sortDate: -1,
    constructor(props) {
        super(props);
        this.state = {
            ...
            loadingMore: false,
        };
        ...
        this.onScroll = this.onScroll.bind(this);
 }

задача - подключить react к существующему проекту на rails

in Gemfile

# for react
gem 'webpacker', '~> 3.4'

installing Webpacker

bundle exec rails webpacker:install
# then in a existing Rails app already setup with Webpacker run this