mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
test: init jest test
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
['@babel/preset-env', {targets: {node: 'current'}}],
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
};
|
||||
+5
-1
@@ -64,7 +64,7 @@
|
||||
},
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"**/test/**/*.js"
|
||||
"**/test/**/*.ts"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
@@ -150,6 +150,9 @@
|
||||
"xxhash-wasm": "1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "7.23.9",
|
||||
"@babel/preset-typescript": "7.23.3",
|
||||
"@jest/globals": "29.7.0",
|
||||
"@microsoft/eslint-formatter-sarif": "3.0.0",
|
||||
"@stylistic/eslint-plugin-js": "1.5.4",
|
||||
"@types/aes-js": "3.1.4",
|
||||
@@ -211,6 +214,7 @@
|
||||
"supertest": "6.3.4",
|
||||
"to-vfile": "8.0.0",
|
||||
"tosource": "2.0.0-alpha.3",
|
||||
"ts-jest": "29.1.2",
|
||||
"tsx": "4.7.0",
|
||||
"unified": "9.2.2",
|
||||
"unist-util-visit": "4.1.2",
|
||||
|
||||
Generated
+1122
-6
File diff suppressed because it is too large
Load Diff
-16
@@ -1,16 +0,0 @@
|
||||
const supertest = require('supertest');
|
||||
const server = require('../lib/index');
|
||||
const request = supertest(server);
|
||||
|
||||
afterAll(() => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
describe('index', () => {
|
||||
it('serve logo', async () => {
|
||||
const response = await request.get('/logo.png');
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers['content-type']).toBe('image/png');
|
||||
expect(response.headers['content-length']).toBe('89034');
|
||||
});
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { describe, expect, it } from '@jest/globals';
|
||||
|
||||
import app from '../lib/app';
|
||||
|
||||
describe('index', () => {
|
||||
it('serve index', async () => {
|
||||
const res = await app.request('/')
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.text()).toContain('Welcome to RSSHub!')
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user