小编Ala*_*nIb的帖子

找不到 Jest 配置 setupFilesAfterEnv 选项

我正在尝试让 Jest 再次在 1 年前开发且未维护的项目上工作。

\n

setupFilesAfterEnv我的or路径有错误transform

\n
    \n
  • 当我运行“纱线测试”时出现错误

    \n
    $ jest __testsv2__ --config=./jest.config.js\n\xe2\x97\x8f Validation Error:\n\nModule <rootDir>/jest/setup.js in the setupFilesAfterEnv option was not found.\n       <rootDir> is: /Users/alain/dev/ddf/release\n\nConfiguration Documentation:\nhttps://jestjs.io/docs/configuration.html\n\nerror Command failed with exit code 1.\n
    Run Code Online (Sandbox Code Playgroud)\n
  • \n
  • 我的文件系统,在 /Users/alain/dev/ddf/release/ 我有

    \n
      babel.config.js\n  jest.config.js\n  /jest\n    /setup\n    setup.js ( so  full path is : /Users/alain/dev/ddf/release/jest/setup.js ) \n    staticFileAssetTransform.js ( so full path is : /Users/alain/dev/ddf/release/jest/staticFileAssetTransform.js )     \n
    Run Code Online (Sandbox Code Playgroud)\n
  • \n
  • 我的package.json

    \n
    { ...\n "scripts": {\n      "test": "jest __testsv2__ --config=./jest.config.js"\n …
    Run Code Online (Sandbox Code Playgroud)

path jestjs

28
推荐指数
2
解决办法
3万
查看次数

elasticsearch映射tokenizer关键字以避免拆分令牌并启用通配符

例如,我尝试在给定字段上使用angularjs和elasticsearch创建自动完成功能countryname.它可以包含简单的名称,如"法国","西班牙"或"组合名称",如"塞拉利昂".

在映射中,此字段not_analyzed用于防止弹性标记化"组合名称"

"COUNTRYNAME" : {"type" : "string", "store" : "yes","index": "not_analyzed" }
Run Code Online (Sandbox Code Playgroud)

我需要查询elasticsearch:

  • 使用类似"countryname:value"的内容过滤文档,其中value可以包含通配符
  • 并对过滤器返回的国家/地区名称进行汇总,(我只进行汇总以获取不同的数据,这对我来说计数没用,也许有更好的解决方案)

我不能在"not_analyzed"字段中使用通配符:

这是我的查询,但"value"变量中的通配符不起作用且区分大小写:

她的工作单独使用通配符:

curl -XGET 'local_host:9200/botanic/specimens/_search?size=0' -d '{
  "fields": [
    "COUNTRYNAME"
  ],
  "query": {
    "query_string": {
      "query": "COUNTRYNAME:*"
    }
  },
  "aggs": {
    "general": {
      "terms": {
        "field": "COUNTRYNAME",
        "size": 0
      }
    }
  }
}'
Run Code Online (Sandbox Code Playgroud)

但这不起作用(法郎*):

curl -XGET 'local_host:9200/botanic/specimens/_search?size=0' -d '{
  "fields": [
    "COUNTRYNAME"
  ],
  "query": {
    "query_string": {
      "query": "COUNTRYNAME:Franc*"
    }
  },
  "aggs": {
    "general": {
      "terms": {
        "field": "COUNTRYNAME",
        "size": …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

12
推荐指数
1
解决办法
1万
查看次数

在包含JsonIdentityInfo的JavaScript中反序列化Jackson对象

你好(对不起我的英文)

我正在使用angularjs前端网站,使用SPRING MVC生成json的web服务.spring mvc使用JsonIdentityInfo选项进行seralization,因此每个对象只在json中写入一次,并且每次使用一个引用,例如她有2个"计算机"使用相同的对象"component",所以spring将id设置为第一个组件("@componentID":2)和第二个组件juste id(2):

[
  {
    "@computerID": 1,
    "component": {
      "@componentID": 2,
      "processor": 2,
      "ram": "8g",
      "harddrive": "wd"
    }
  },
  {
    "@computerID": 3,
    "component": 2
  }
]
Run Code Online (Sandbox Code Playgroud)

我想要的是 :

[
  {
    "@computerID": 1,
    "owner" : "Mister B",
    "component": {
      "@componentID": 2,
      "processor": 2,
      "ram": "8g",
      "harddrive": "wd"
    }
  },
  {
    "@computerID": 3,
    "owner" : "Mister A",
    "component": {
      "@componentID": 2,
      "processor": 2,
      "ram": "8g",
      "harddrive": "wd"
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

我做了很多搜索代码谁做了这个,但我没有发现任何想法.

我无法编辑Web服务以删除此行为.我可以使用javascript或jquery(或其他librairie)编辑客户端的json,以用真实引用的对象替换引用吗?(数据实际上更复杂,更深,我在对象中有3级子对象).

非常感谢.

javascript spring json angularjs jsonidentityinfo

9
推荐指数
2
解决办法
7255
查看次数

react-native 地铁包卡住了,没有运行进度条

我在 IOS 和 ANDROID 上从事 react-native 项目。

在 IOS 上,metro bundler 控制台停留在

Metro Bundler ready.
Loading dependency graph, done.
Run Code Online (Sandbox Code Playgroud)

即使延迟了很长时间也没有任何反应。它应该执行以下操作:

Metro Bundler ready.
Loading dependency graph, done.
BUNDLE  [android, dev] ./index.android.js ???????????????? 0.0%       (0/1)Launching Dev Tools...
BUNDLE  [android, dev] ./index.android.js ???????????????? 100.0% (982/982), done.
BUNDLE  [android, dev] ./index.android.js ???????????????? 100.0% (1/1), done.
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

我尝试删除 node_modules ,通过 Xcode 清理项目,运行“npm start”

react-native

8
推荐指数
1
解决办法
6332
查看次数

如何缩短这个JS函数

我有这个带有硬编码过滤器参数的 Js 函数。当键以给定列表中的字符串开头时,它会过滤所有存储桶子对象。目前我还没有找到一种方法将此列表作为数组......

\n
     function filter(buckets) {\n      return buckets.filter(({key}) => {\n        const _key = key.toLowerCase();\n        return (\n          !_key.startsWith("anciennes") && !_key.startsWith("anciens") && !_key.startsWith("arrondissements") && !_key.startsWith("autorites") && !_key.startsWith("cantons") && !_key.startsWith("capitales") &&\n          !_key.startsWith("chaines") && !_key.startsWith("chefs lieux") && !_key.startsWith("circonscriptions") && !_key.startsWith("communautes d") && !_key.startsWith("comtes d") && !_key.startsWith("constellations") && !_key.startsWith("continents") &&\n          !_key.startsWith("cours d") && !_key.startsWith("d\xc3\xa9partements") && !_key.startsWith("districts d") && !_key.startsWith("\xc3\xa9tablissements") && !_key.startsWith("\xc3\xa9tats") && !_key.startsWith("ethnonymes") && !_key.startsWith("\xc3\xa9toiles") &&\n          !_key.startsWith("europe") && !_key.startsWith("\xc3\xaeles") && !_key.startsWith("lander-allemands") && !_key.startsWith("lieux-mythologiques") && !_key.startsWith("Localit\xc3\xa9s d") && !_key.startsWith("mers") &&\n          !_key.startsWith("montagnes") && !_key.startsWith("municipalit\xc3\xa9") && !_key.startsWith("fromage") …
Run Code Online (Sandbox Code Playgroud)

javascript

7
推荐指数
1
解决办法
235
查看次数

无需登录调试模式即可反应本机应用程序崩溃

我正在使用最新版本的react和react-native:

"react": "16.1.1",
"react-native": "^0.50.3"
Run Code Online (Sandbox Code Playgroud)

有时我的应用程序崩溃完全关闭没有任何登录铬,我没有得到手机上的红色屏幕,我当然处于调试模式,并得到通常的错误或登录Chrome控制台.

例如,使用此视图,我渲染相同的数据.渲染1运行良好,不会使应用程序崩溃.渲染2适用于少数几行应用程序崩溃

在此输入图像描述

我得到了应用程序崩溃,没有任何其他类型的日志(例如道具中缺少参数).

有什么方法可以追踪或解决这个问题 我没有找到本地工具

javascript react-native

6
推荐指数
1
解决办法
2988
查看次数

elasticsearch上的autocomplete/typeahead angularjs bootstrap

我正在寻找一个有效的解决方案,以在elasticsearch服务器上使用angularjs和bootstrap获得自动完成/预先输入.

autocomplete elasticsearch twitter-bootstrap angularjs

5
推荐指数
1
解决办法
2943
查看次数

更改从 chrome 扩展名做出反应的输入值

我在 Chrome 扩展程序上工作,我需要根据从 CSV 读取的数字更新使用 React 制作的 html 页面的大量输入。我无法更新网站。

- 从渲染网站复制的输入示例:

  <td><input class="input input_small fpInput" value="29,4"></td>
Run Code Online (Sandbox Code Playgroud)

- 它是如何制作的(不确定 100%,必须阅读丑陋的 js 源代码)

{
    key: "render",
    value: function () {
        return s.a.createElement("input", {
            className: "input input_small fpInput",
            value: this.state.value,
            onChange: this.handleChange,
            onBlur: this.handleSubmit,
            onFocus: this.handleFocus
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

- 每次更改输入值时,都会调用一个函数并进行 POST 以保存它。

我想在更改输入值以触发 POST 后从我的扩展中触发onBlur()onChange()

我试过这个:

var el = document. ... .querySelector('input'); // the selector is simplied of course
el.value = 321;
el.onChange();  // ERROR onChange is not a …
Run Code Online (Sandbox Code Playgroud)

google-chrome-extension reactjs

5
推荐指数
2
解决办法
2121
查看次数

react-native fetch返回状态码+ json

我在react-native中使用fetch来进行API调用.

我需要获取状态代码(200,401,404)和响应数据.

这项工作来获取响应数据:

return fetch(url)
.then(response => {
  return response.json();
})
.then(res => {
  console.log("reponse :", res); // <-------- res is ok with data
 })    .catch(error => {
  console.error(error);
  return { name: "network error", description: "" };
});
Run Code Online (Sandbox Code Playgroud)

现在我调整第一个然后获取状态代码但数据不是我除了

return fetch(url)
.then(response => {
  const statusCode = response.status;
  const data = response.json();
  return { statusCode, data };
})
.then(res => {
  console.log("reponse :", res); // <-------- i get a "promise"
 }).catch(error => {
  console.error(error);
  return { name: "network error", description: …
Run Code Online (Sandbox Code Playgroud)

fetch promise react-native

4
推荐指数
1
解决办法
1万
查看次数

Reactjs 传递组件数组

我正在尝试将一组组件传递给另一个组件,并在添加其他道具后渲染它们

import {ComponentB} from ".../ComponentB";


<ComponentA 
    list={[
       <ComponentB title={'title 1'} />,
       <ComponentB title={'title 2'} />,
       <ComponentB title={'title 3'} />
    ]} />
Run Code Online (Sandbox Code Playgroud)

如何循环遍历list中的 props ComponentA?这不起作用:

// 组件A

    { list.map((Item, index) => {
        return (
            <Item otherProps={'value xxx'}/>
        )
    })}         
Run Code Online (Sandbox Code Playgroud)

这是可以的,但不能添加道具

    { list.map((Item, index) => {
        return (
            {Item}
        )
    })} 
Run Code Online (Sandbox Code Playgroud)

reactjs

4
推荐指数
1
解决办法
1101
查看次数

计算其他表中的值

我有两张桌子= subjectsstats.

  -- subjects --             
------------------          
|  id  | name    |          
------------------         
|  1  |  subjecta |        
|  2  |  subjectb |       
|  3  |  subjectc |         
|  4  |  subjectd |         
|  5  |  subjecte |        
|  6  |  subjectf |        
|  7  |  subjectg |      
|  8  |  subjecth |         
|  9  |  subjecte |       
| ... |  subjectf |       
------------------       

-- stats --
-----------------------------------
| user_id | subject_id | correct  |
-----------------------------------
|  1 …
Run Code Online (Sandbox Code Playgroud)

sql postgresql

2
推荐指数
1
解决办法
40
查看次数

从提供者App.js反应本机调用操作

我使用react native和redux作为以下(工作):

App.js

export default class App extends React.PureComponent {
  constructor (props) {
    super(props);

    this.state = { ...store.getState()};
    store.subscribe(() => {
      // i can read the state but no write it
      const storestate = store.getState();       
    });
  }

  handleConnectivityChange = isConnected => {
    this.setState({ isConnected });
  };

  render() {
    return (
      <Provider store={store}>
        <PersistGate
          loading={<ActivityIndicator />}
          persistor={persistor}>

          <View style={{ flex: 1, marginTop: Config.marginTop }}>
            <StackView />

          </View>
        </PersistGate>
      </Provider>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

ScreenX.js

import * as actions from "./redux/actions";
import { …
Run Code Online (Sandbox Code Playgroud)

react-native redux react-redux

0
推荐指数
1
解决办法
2160
查看次数