I am trying to import #aws/dynamo-data-mapper package from AWS. flow isn't recognizing the packages with #.
// #flow
import Joi from 'joi';
import { DataMapper } from '#aws/dynamo-data-mapper';
import DynamoDB from 'aws-sdk/clients/dynamodb';
Running flow is giving below error
Cannot resolve module #aws/dynamo-data-mapper.
1│ // #flow
2│ import Joi from 'joi';
3│ import { DataMapper } from '#aws/dynamo-data-mapper';
4│ import DynamoDB from 'aws-sdk/clients/dynamodb';
Wondering how to make flow recognize the packages that start with #.
Related
In the version 3 of apollo server, we could use import {gql} from "apollo-server-express" to create typedefs and schemas. But in v4 of apollo server, apollo-server-express and apollo-server-core are depreciated and will be removed. So, instead of importing gql from apollo-server-express, how can we import gql
I tried import gql from new #apollo/server and it is not working either.
import { gql } from "#apollo/server";
const typeDefs = gql``;
With Apollo v4 you should now import qgl from the graphql-tag package.
import gql from 'graphql-tag';
We are using pusher-js in our chrome extension application to connect with backend messaging.
Till manifest V2, It worked perfectly fine. But post manifest V3 migration, pusher-js is throwing Uncaught ReferenceError: window is not defined while doing load-unpacked.
I event tried updating the pusher-js npm package, but dint worked.
I am well know that window object is not available in new manifest V3. But how to make pusher-js work in my chrome extension.
This error happens as soon as I import the pusher from pusher-js.
Removing the pusher import, code works perfectly. Can anyone help me on this?
import code pusher
/* global chrome */
// import Config from '../config';
import StatusChecker from '../utils/status-checker';
import StatusCheckerNotifier from '../utils/status-checker-notifier';
import loggingService from '../utils/logging-service';
import fetchProvider from '../fetch';
import fetchGraphqlProvider from '../fetch-graphql';
import { addLinkedInCsrfTokenHeader } from './csrf-token-header';
import LoggingService from './services/LoggingService';
import FetchableService from './services/FetchableService';
import ContractChooserResolver from './services/ContractChooserResolver';
import dispatcher from '../dispatcher';
import ContextRuntime from '../contextruntime';
import { pusherInit } from './pusher-init';
import { SIDEBAR_EVENTS } from '../constants';
import * as Utils from './helpers';
class GoldmineBackend {
init(userMeta) {
console.log('testing');
}
}
export default new GoldmineBackend();
service-worker console error
service-worker console error - source
build load-unpacked error
I'm trying to mock a destructed import with Jest.
In the component is the destructed import:
import { getSomething } from 'utils/paymentUtils';
In the test:
import React from 'react';
import { shallow } from 'enzyme';
import Component from 'components/Component';
import * as utils from 'utils/paymentUtils';
jest.mock('utils');
describe('Something', () => {
let wrapper;
utils.getSomething.mockImplementation(() => 'Blah');
The error I'm getting is:
Cannot find module 'utils' from 'Component.spec.js'
You have to mock the module itself, in this case utils/paymentUtils
I am trying out the new Node 12 module import syntax and cannot get static functions from rxjs to work.
I've tried both Typescript-style import syntax and ideas from the new module documentation.
// SyntaxError: The requested module 'rxjs' does not provide an export named 'interval'
import { interval } from 'rxjs';
const x = interval(1000)
// TypeError: interval is not a function
import interval from 'rxjs';
const x = interval(1000)
// TypeError: interval is not a function
import interval from 'rxjs/observable/interval.js';
const x = interval(1000)
Any idea what the correct way is to import static functions?
UPDATE: One way that works:
import Observable from 'rxjs';
const x = Observable.interval(1000).subscribe(() =>
console.log('' + new Date().toISOString())
)
I am creating a forced graph in react using d3 for npm.
The graph is created using the follows:
https://medium.com/walmartlabs/d3v4-forcesimulation-with-react-8b1d84364721
I am trying to set up the testing environment as follows:
https://ericnish.io/blog/how-to-unit-test-react-components-with-enzyme/
the problem is when I run the test I keep on getting
Cannot read property 'matches' of undefined
at C:\workspace\project\node_modules\d3-selection\build\d3-selection.js:83:15
I have imported d3 in my graph component as follows:
import * as d3 from 'd3';
It seems like when I import my react component in my test file, it freaks out. This is my test file:
import React from 'react'
import {shallow, mount, render} from 'enzyme'
import {expect} from 'chai'
import * as d3 from 'd3';
import graph from '.../components/graph ';
describe('graph ', () => {
it('should have the main svg', (done) => {
const wrapper = shallow(<graph />);
expect(wrapper.find('svg')).to.have.length(1);
done()
})
})
How can I get rid of this error?
Create a file, e.g. polyfill.js:
global.document.documentElement = {matches: () => false};
And import it right before you import DS3 (or any other import that transitively imports D3):
import React from 'react'
import {shallow, mount, render} from 'enzyme'
import {expect} from 'chai'
import './polyfill';
import * as d3 from 'd3';