排毒模拟文件

时间:2018-10-29 15:23:16

标签: react-native detox

我正在使用Detox 9.0.4和React-native 0.57.2,并试图模拟文件。 在他们的documentation之后,我在运行构建时添加了$ dig @g.root-servers.net red. NS +nocookie ; <<>> DiG 9.12.0 <<>> @g.root-servers.net red. NS +nocookie ; (1 server found) ;; global options: +cmd ;; Sending: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18270 ;; flags: rd ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;red. IN NS ;; QUERY SIZE: 32 ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18270 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 9 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;red. IN NS ;; AUTHORITY SECTION: red. 172800 IN NS b0.nic.red. red. 172800 IN NS c0.nic.red. red. 172800 IN NS a2.nic.red. red. 172800 IN NS a0.nic.red. ;; ADDITIONAL SECTION: a0.nic.red. 172800 IN A 65.22.36.25 a2.nic.red. 172800 IN A 65.22.39.25 b0.nic.red. 172800 IN A 65.22.37.25 c0.nic.red. 172800 IN A 65.22.38.25 a0.nic.red. 172800 IN AAAA 2a01:8840:26::25 a2.nic.red. 172800 IN AAAA 2a01:8840:29::25 b0.nic.red. 172800 IN AAAA 2a01:8840:27::25 c0.nic.red. 172800 IN AAAA 2a01:8840:28::25 ;; Query time: 104 msec ;; SERVER: 192.112.36.4#53(192.112.36.4) ;; WHEN: Mon Oct 29 10:20:35 EST 2018 ;; MSG SIZE rcvd: 280 env变量,并将$ dig @g.root-servers.net www.stackoverflow.com. NS +nocookie ; <<>> DiG 9.12.0 <<>> @g.root-servers.net www.stackoverflow.com. NS +nocookie ; (1 server found) ;; global options: +cmd ;; Sending: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8649 ;; flags: rd ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;www.stackoverflow.com. IN NS ;; QUERY SIZE: 50 ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8649 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 27 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;www.stackoverflow.com. IN NS ;; AUTHORITY SECTION: com. 172800 IN NS j.gtld-servers.net. com. 172800 IN NS g.gtld-servers.net. com. 172800 IN NS a.gtld-servers.net. com. 172800 IN NS d.gtld-servers.net. com. 172800 IN NS m.gtld-servers.net. com. 172800 IN NS e.gtld-servers.net. com. 172800 IN NS i.gtld-servers.net. com. 172800 IN NS f.gtld-servers.net. com. 172800 IN NS k.gtld-servers.net. com. 172800 IN NS l.gtld-servers.net. com. 172800 IN NS b.gtld-servers.net. com. 172800 IN NS c.gtld-servers.net. com. 172800 IN NS h.gtld-servers.net. ;; ADDITIONAL SECTION: a.gtld-servers.net. 172800 IN A 192.5.6.30 b.gtld-servers.net. 172800 IN A 192.33.14.30 c.gtld-servers.net. 172800 IN A 192.26.92.30 d.gtld-servers.net. 172800 IN A 192.31.80.30 e.gtld-servers.net. 172800 IN A 192.12.94.30 f.gtld-servers.net. 172800 IN A 192.35.51.30 g.gtld-servers.net. 172800 IN A 192.42.93.30 h.gtld-servers.net. 172800 IN A 192.54.112.30 i.gtld-servers.net. 172800 IN A 192.43.172.30 j.gtld-servers.net. 172800 IN A 192.48.79.30 k.gtld-servers.net. 172800 IN A 192.52.178.30 l.gtld-servers.net. 172800 IN A 192.41.162.30 m.gtld-servers.net. 172800 IN A 192.55.83.30 a.gtld-servers.net. 172800 IN AAAA 2001:503:a83e::2:30 b.gtld-servers.net. 172800 IN AAAA 2001:503:231d::2:30 c.gtld-servers.net. 172800 IN AAAA 2001:503:83eb::30 d.gtld-servers.net. 172800 IN AAAA 2001:500:856e::30 e.gtld-servers.net. 172800 IN AAAA 2001:502:1ca1::30 f.gtld-servers.net. 172800 IN AAAA 2001:503:d414::30 g.gtld-servers.net. 172800 IN AAAA 2001:503:eea3::30 h.gtld-servers.net. 172800 IN AAAA 2001:502:8cc::30 i.gtld-servers.net. 172800 IN AAAA 2001:503:39c1::30 j.gtld-servers.net. 172800 IN AAAA 2001:502:7094::30 k.gtld-servers.net. 172800 IN AAAA 2001:503:d2d::30 l.gtld-servers.net. 172800 IN AAAA 2001:500:d937::30 m.gtld-servers.net. 172800 IN AAAA 2001:501:b1f9::30 ;; Query time: 105 msec ;; SERVER: 192.112.36.4#53(192.112.36.4) ;; WHEN: Mon Oct 29 10:21:50 EST 2018 ;; MSG SIZE rcvd: 846 添加到了我们的打包程序配置(RN_SRC_EXT=e2e.js)中。

这很好,直到我们将React-Native升级到使用更新的Metro Bundler的0.57,所以我相应地更改了getSourceExts: () => process.env.RN_SRC_EXT ? process.env.RN_SRC_EXT.split(',') : []

rn-cli.config.js

但是rn-cli.config.js导致常规构建失败。

我该如何解决?

1 个答案:

答案 0 :(得分:0)

如果您未明确指定新语法,则新语法似乎不会使用JS文件,因此解决方案是在每种情况下都添加它。

rn-cli.config.js文件:

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
  resolver: {
    blacklistRE: blacklist([/react-native\/local-cli\/core\/__fixtures__.*/]),
    sourceExts: process.env.RN_SRC_EXT ? process.env.RN_SRC_EXT.split(',') : []
  }
};

当您传递RN_SRC_EXT变量(在我的例子中是在npm命令中)时,我还传递了'js'作为第二个扩展名:

"test:e2e-build": "RN_SRC_EXT='e2e.js,js' detox build -c ios.sim.release"