我正在尝试为我在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
答案 0 :(得分:1)
您需要在Chrome中打开chrome:// inspect,应该在“设备”标签上,然后单击“打开Node专用的DevTools”
这也有助于放置调试器;在您想要破坏的来源中。