mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
improve error of node tests (#3928)
remove unused imports and fail without revealing the token
This commit is contained in:
@@ -1,33 +1,29 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
import DeltaChat, { Message } from '../dist'
|
import DeltaChat from '../dist'
|
||||||
import binding from '../binding'
|
|
||||||
|
|
||||||
import { deepEqual, deepStrictEqual, strictEqual } from 'assert'
|
import { deepStrictEqual, strictEqual } from 'assert'
|
||||||
import chai, { expect } from 'chai'
|
import chai, { expect } from 'chai'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import chaiAsPromised from 'chai-as-promised'
|
||||||
import { EventId2EventName, C } from '../dist/constants'
|
import { EventId2EventName, C } from '../dist/constants'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { mkdtempSync, statSync } from 'fs'
|
import { statSync } from 'fs'
|
||||||
import { tmpdir } from 'os'
|
|
||||||
import { Context } from '../dist/context'
|
import { Context } from '../dist/context'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
chai.config.truncateThreshold = 0; // Do not truncate assertion errors.
|
chai.config.truncateThreshold = 0 // Do not truncate assertion errors.
|
||||||
|
|
||||||
async function createTempUser(url) {
|
async function createTempUser(url) {
|
||||||
const fetch = require('node-fetch')
|
|
||||||
|
|
||||||
async function postData(url = '') {
|
async function postData(url = '') {
|
||||||
// Default options are marked with *
|
// Default options are marked with *
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
||||||
mode: 'cors', // no-cors, *cors, same-origin
|
|
||||||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
|
||||||
credentials: 'same-origin', // include, *same-origin, omit
|
|
||||||
headers: {
|
headers: {
|
||||||
'cache-control': 'no-cache',
|
'cache-control': 'no-cache',
|
||||||
},
|
},
|
||||||
referrerPolicy: 'no-referrer', // no-referrer, *client
|
|
||||||
})
|
})
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('request failed: ' + response.body.read())
|
||||||
|
}
|
||||||
return response.json() // parses JSON response into native JavaScript objects
|
return response.json() // parses JSON response into native JavaScript objects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user