使用Jest和Expo时如何在React Native中调试测试

问题描述

我正在尝试为我在Expo上使用React native构建的应用中的测试设置一些调试功能。我遵循了在线资源中的一些说明。以下是我的package.json中的设置。当我使用此脚本from turtle import Screen,Turtle WIDTH,HEIGHT = 1280,720 TILE_SIZE = 10 CURSOR_SIZE = 20 def square(color): turtle.fillcolor(color) turtle.stamp() def paint_line(text): ''' The paint line() function shall take one parameter as input,a string representing a line from a text file,and draw a row of colorful squares corresponding to the characters in the line. After drawing the row,the turtle shall go to the beginning of the next row to be ready to paint the next line,if any. ''' for character in text: code = ord(character) if code < 70: square('black') elif 70 <= code < 100: square('pink') elif 100 <= code < 110: square('light blue') elif 110 <= code < 122: square('yellow') elif code >= 122: square('green') # to print each line of text on a different row turtle.forward(10) #do not use readlines() def picture(file_name): ''' The picture() function takes one parameter as input,a file name,opens the file,and draws the picture by calling the paint line() function for each line of text in the file. ''' with open(file_name + ".txt") as file_data: for line,text in enumerate(file_data,start=1): print("Line {}: {}".format(line,text.strip())) paint_line(text) turtle.goto(-WIDTH/2 + TILE_SIZE,turtle.ycor() - TILE_SIZE) def main(): ''' The main() function prompts the user for a file name and calls picture() to do the work. ''' file_name = input("Enter the file name: ") picture(file_name) screen = Screen() screen.setup(WIDTH,HEIGHT) turtle = Turtle() turtle.shape('square') turtle.shapesize(TILE_SIZE / CURSOR_SIZE) turtle.speed('fastest') turtle.penup() # The drawing starts near the upper left corner of the canvas. turtle.goto(-WIDTH/2 + TILE_SIZE,HEIGHT/2 - TILE_SIZE) main() screen.exitonclick() 运行测试时 我在chrome开发工具中看到了断点,然后继续,我在控制台上看到了一些警告,但没有其他警告。

我什至不确定我应该看到什么。即使没有错误,也会有一些输出吗?万一我故意在测试中犯了一个错误,但控制台上仍然没有任何错误。可能是因为这些警告吗?

Package.json

node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand

enter image description here

解决方法

您需要在Chrome中打开chrome:// inspect,应该在“设备”标签上,然后单击“打开Node专用的DevTools”

这也有助于放置调试器;在您想要破坏的来源中。

Chrome Screen Shot

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...