我有以下代码用于打印到 PDF(并且可以正常工作),并且我仅使用 Google Chrome 进行打印。
def send_devtools(driver, command, params=None):
# pylint: disable=protected-access
if params is None:
params = {}
resource = "/session/%s/chromium/send_command_and_get_result" % driver.session_id
url = driver.command_executor._url + resource
body = json.dumps({"cmd": command, "params": params})
resp = driver.command_executor._request("POST", url, body)
return resp.get("value")
def export_pdf(driver):
command = "Page.printToPDF"
params = {"format": "A4"}
result = send_devtools(driver, command, params)
data = result.get("data")
return data
Run Code Online (Sandbox Code Playgroud)
正如我们所看到的,我使用Page.printToPDF打印到base64,并format在params参数上传递“A4” 。
不幸的是,这个参数似乎被忽略了。我看到一些使用puppeteer 的代码(格式 A4),我认为这可以帮助我。
即使使用硬编码的宽度和高度(见下文),我也没有运气。
"paperWidth": 8.27, # …Run Code Online (Sandbox Code Playgroud) 我正在使用 Parcel 来捆绑我的项目并使用 jest 来运行我的测试。
一切正常,但在我有async/await关键字的测试中,我必须导入regenerator-runtime/runtime
像这样:
import "regenerator-runtime/runtime"
test("read armored key", async() => {
})
Run Code Online (Sandbox Code Playgroud)
还有这个作品。
但是如果没有这个 import ( import "regenerator-runtime/runtime") 我收到了这个错误消息:
ReferenceError: regeneratorRuntime is not defined
Run Code Online (Sandbox Code Playgroud)
如何更改我的项目以在异步测试中不进行此导入的情况下运行?
示例: https: //github.com/skhaz/parcel-regeneratorRuntime-is-not-define
我在一个项目中看到使用create-react-app一个名为的文件,setupTest.js该文件只是导入@testing-library/jest-dom,并且测试似乎使用扩展expect版本,例如.toBeInTheDocument.
我将相同的文件(setupTest.js)添加到我的项目中,但似乎没有效果。
换句话说,如何@testing-library/jest-dom全局导入而不是在每个.spec.ts文件中执行?
我在使用 firebase 模拟器运行 Jest 时收到警告
警告
{"severity":"WARNING","message":"Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail"}
Run Code Online (Sandbox Code Playgroud)
我的测试用例
describe('Functions', () => {
const testEnv = functions()
let firestore: admin.firestore.Firestore
beforeAll(() => {
const projectId = 'sample'
process.env.GCLOUD_PROJECT = projectId
process.env.FIRESTORE_EMULATOR_HOST = 'localhost:8080'
admin.initializeApp({ projectId })
firestore = admin.firestore()
})
afterAll(() => {})
})
Run Code Online (Sandbox Code Playgroud) 我刚刚使用创建了一个新项目
npx create-next-app@latest --ts
Run Code Online (Sandbox Code Playgroud)
当我跑步时
npm run lint
Run Code Online (Sandbox Code Playgroud)
我收到错误:
next lint 信息 - 使用 webpack 5。原因:默认启用https://nextjs.org/docs/messages/webpack5 错误 - 必须安装 ESLint:yarn add --dev eslint
但eslint已经安装了!
可能是什么?
重现步骤:
npx create-next-app@latest --ts
cd app
npm install
npm run lint
Run Code Online (Sandbox Code Playgroud)
我的package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:css": "stylelint '**/*.{css,tsx}'",
"format": "prettier '**/*' --write --ignore-unknown",
"prepare": "husky install"
},
"dependencies": {
"next": "11.1.2",
"react": "17.0.2", …Run Code Online (Sandbox Code Playgroud) 我正在将库升级到最新版本的 SQLAlchemy,但收到此错误
类型对象“Base”没有属性“_decl_class_registry”
在线的
Base = declarative_base(metadata=metadata)
Base._decl_class_registry
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我正在使用 firebase 模拟器来运行我的笑话测试:
\n包.json:
\n{\n"scripts": {\n "test": "firebase emulators:exec --only firestore --project sample jest",\n },\n}\nRun Code Online (Sandbox Code Playgroud)\n笑话.config.json:
\n{\n "preset": "ts-jest",\n "testEnvironment": "node",\n "modulePathIgnorePatterns": ["<rootDir>/lib/"]\n}\nRun Code Online (Sandbox Code Playgroud)\n当我运行时,我收到以下消息
\n\n\n工作进程未能正常退出,已被强制退出。这可能是由于拆卸不当导致测试泄漏造成的。尝试使用 --detectOpenHandles 运行来查找泄漏。
\n
运行时--detectOpenHandles我什么也没看到
npm test\n\n> functions@ test /home/ubuntu/workspace/blinktrade/otc/firebase/functions\n> firebase emulators:exec --only firestore --project sample \'jest --detectOpenHandles\'\n\ni emulators: Starting emulators: firestore\ni firestore: Firestore Emulator logging to firestore-debug.log\ni Running script: jest --detectOpenHandles\n PASS tests/index.test.ts\n \xe2\x97\x8f Console\n\n console.warn\n {"severity":"WARNING","message":"Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing …Run Code Online (Sandbox Code Playgroud) 如何使用打字稿中对象的键的索引来获取属性?
尽管 TypeScript 出现错误,但代码可以正常工作。
我的代码
const payments = {
KEY1: {prop1: "prop1"},
KEY2: {prop1: "prop1"}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试按键值访问时出现错误
const index = 0
const key = Object.keys(payments)[index]
const payment = payments[key] // ERROR HERE
Run Code Online (Sandbox Code Playgroud)
元素隐式具有“any”类型,因为“string”类型的表达式不能用于索引类型“{}”。在类型“{}”上找不到带有“string”类型参数的索引签名。ts(7053)
payments是对象类型
有没有办法检查 Docker 上运行的镜像是 ARM 还是 Intel?
我正在运行官方 Postgres docker 映像,我想知道它是 ARM 还是 Intel
我在 gorm 中有以下模型
type Person struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4()"`
Name string `gorm:"not null,type:text"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index,->"`
}
Run Code Online (Sandbox Code Playgroud)
是否可以获取列名?我想要 gorm 将生成的列名
firebase ×2
jestjs ×2
python ×2
typescript ×2
babeljs ×1
docker ×1
go ×1
go-gorm ×1
javascript ×1
next.js ×1
parceljs ×1
selenium ×1
sqlalchemy ×1