我已经从该站点的material-ui测试页面中举了一个例子。我已经使用create-react-app制作了该应用,并将酶导入了我的项目。
import { createMount } from '@material-ui/core/test-utils';
import MyComponent from './src/MyComponent';
describe('<MyComponent />', () => {
let mount;
before(() => {
mount = createMount();
});
after(() => {
mount.cleanUp();
});
it('should work', () => {
const wrapper = mount(<MyComponent />);
});
});
我所有的测试均无法运行并引发以下错误
ReferenceError: before is not defined
我读过的任何地方都不需要配置玩笑,因为它与create-react-app开箱即用。下面是我的package.json,我应该如何配置我的应用程序以便可以运行这些测试?
{
"name": "client",
"version": "1.3.0",
"private": true,
"license": "private",
"proxy": {
"/media/*": {
"target": "website"
},
"/updates/*": {
"target": "website"
},
"/okta/*": {
"target": "website"
}
},
"homepage": "http:website",
"dependencies": {
"@material-ui/core": "^1.5.1",
"@material-ui/icons": "^2.0.3",
"axios": "^0.17.1",
"lodash": "^4.17.4",
"material-ui-pickers": "^1.0.0-beta.12",
"materialize-css": "^0.100.2",
"moment": "^2.20.1",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-addons-shallow-compare": "^15.6.2",
"react-dates": "^16.0.1",
"react-day-picker": "^7.0.7",
"react-dom": "^16.2.0",
"react-props": "^0.0.3",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.17",
"react-with-direction": "^1.1.0",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-saga": "^0.16.0",
"redux-thunk": "^2.2.0",
"universal-cookie": "^2.1.2",
"video.js": "^6.6.0",
"videojs-contrib-hls.js": "^3.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"jest-enzyme": "^6.0.4"
}
答案 0 :(得分:1)
您需要先更改为beforeAll,然后再更改为afterAll
更改
import networkx
import pandas as pd
d = {'Col1': {'row1': 'A1',
'row2': 'A2',
'row3': 'A2',
'row4': 'A3',
'row5': 'B1',
'row6': 'B2'},
'Col2': {'row1': 'A2',
'row2': 'A3',
'row3': 'A4',
'row4': 'A5',
'row5': 'B2',
'row6': 'A3'}}
df = pd.DataFrame(d)
G = nx.from_pandas_edgelist(df, 'Col1', 'Col2', create_using=nx.DiGraph())
master = [n for n in G.nodes if nx.ancestors(G, n)==set()]
descendants = [list(nx.descendants(G,m)) for m in master]
pd.DataFrame({'col1':master,'col2':descendants})
收件人
col1 col2
0 A1 [A3, A5, A4, A2]
1 B1 [A5, A3, B2]