Fix and update tests and use pnpm instead of yarn

pull/17/head
neobooru 2023-11-05 15:09:49 +01:00
parent 18e9b57e12
commit fa6baa75b7
7 changed files with 5330 additions and 6021 deletions

View File

@ -3,13 +3,13 @@
## Run all tests in testfiles matching some pattern
```sh
yarn test pixiv
pnpm test pixiv
```
## Run one specific test ({{describe name}} {{it name}})
```sh
yarn test pixiv -t "get pixiv post 96268450 \(multipage, expanded\) should find exactly four posts"
pnpm test pixiv -t "get pixiv post 96268450 \(multipage, expanded\) should find exactly four posts"
```
For some reason you need to escape the parentheses.
@ -17,7 +17,7 @@ For some reason you need to escape the parentheses.
## Debug puppeteer tests
```sh
yarn test:debug # you can add more arguments if you want
pnpm test:debug # you can add more arguments if you want
```
This will disable headless mode.

View File

@ -1,6 +1,6 @@
module.exports = {
launch: {
headless: process.env.HEADLESS !== "false",
headless: process.env.HEADLESS !== "false" ? "new" : false,
executablePath: process.env.CHROME_BIN || null,
args: process.env.CI ? ["--disable-gpu", "--disable-dev-shm-usage", "--no-sandbox"] : [],
},

View File

@ -18,32 +18,31 @@
"license": "MIT",
"dependencies": {
"js-cookie": "^3.0.5",
"turndown": "^7.1.1"
"turndown": "^7.1.2"
},
"devDependencies": {
"@types/expect-puppeteer": "^4.4.7",
"@types/jest": "^26.0.14",
"@types/jest-environment-puppeteer": "^4.4.1",
"@types/js-cookie": "^3.0.3",
"@types/expect-puppeteer": "^5.0.5",
"@types/jest": "^29.5.7",
"@types/jest-environment-puppeteer": "^5.0.5",
"@types/js-cookie": "^3.0.5",
"@types/jsdom": "^12.2.4",
"@types/puppeteer": "^5.4.4",
"@types/turndown": "^5.0.1",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"@types/turndown": "^5.0.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"cross-env": "^7.0.3",
"eslint": "8.7.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-promise": "^6.0.0",
"jest": "^26.6.3",
"jest-puppeteer": "^6.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.7.0",
"jest-puppeteer": "^9.0.1",
"jest-ts-webcompat-resolver": "^1.0.0",
"jsdom": "^15.2.1",
"prettier": "2.5.1",
"puppeteer": "^13.1.2",
"ts-jest": "^26.5.6",
"puppeteer": "^21.5.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},
"exports": {
".": "./dist/index.js",
@ -59,7 +58,7 @@
"ts",
"js"
],
"testTimeout": 15000,
"testTimeout": 30000,
"testRegex": "^.+\\.test\\.ts$",
"setupFilesAfterEnv": [
"./src/test/jest.setup.ts"

5305
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
import { scrapeUrl } from "../test/engine.js";
test("get chan.sankakucomplex.com post 19614481 with notes", async () => {
const pageUrl = "https://chan.sankakucomplex.com/post/show/507e986a62cc5b866d92ad491dcfb1a4";
const pageUrl = "https://chan.sankakucomplex.com/posts/show/507e986a62cc5b866d92ad491dcfb1a4";
const res = await scrapeUrl(pageUrl);
expect(res.posts.length).toBe(1);
expect(res.posts[0]).toHaveTag("bangs");
@ -18,13 +18,13 @@ test("get chan.sankakucomplex.com post 19614481 with notes", async () => {
test("get chan.sankakucomplex.com post 29354061 with notes", async () => {
// Kinda sketchy
const pageUrl = "https://chan.sankakucomplex.com/post/show/c8376f02608548365d394a658e85cb3f";
const pageUrl = "https://chan.sankakucomplex.com/posts/show/c8376f02608548365d394a658e85cb3f";
const res = await scrapeUrl(pageUrl);
expect(res.posts.length).toBe(1);
expect(res.posts[0]).toHaveTag("bangs");
expect(res.posts[0]).toHaveTag("braid");
expect(res.posts[0]).toHaveTag("sankuro");
expect(res.posts[0]).toHaveNote("No. \nI already told you...");
expect(res.posts[0].notes[0].text).toContain("I already told you");
expect(res.posts[0].pageUrl).toBe(pageUrl);
expect(res.posts[0].contentUrl).toContain("sankakucomplex.com/data/c8/37/c8376f02608548365d394a658e85cb3f.jpg");
});

View File

@ -52,7 +52,7 @@ export default class Zerochan extends ScrapeEngineBase {
}
let category: TagCategory | undefined;
const className = tagElement.className.replace("emphasis", "").trim();
const className = tagElement.classList[0];
switch (className) {
case "game":
case "series":
@ -60,7 +60,6 @@ export default class Zerochan extends ScrapeEngineBase {
category = "copyright";
break;
case "character":
case "character group":
category = "character";
break;
case "mangaka":

5994
yarn.lock

File diff suppressed because it is too large Load Diff