test: __dirnameはESModuleでは使えないので置き換えた (#8626)

This commit is contained in:
iwata
2022-05-14 16:09:47 +09:00
committed by GitHub
parent b2a5076d14
commit ebb4308a5c
6 changed files with 53 additions and 23 deletions

View File

@ -2,8 +2,13 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import * as childProcess from 'child_process';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { async, signup, request, post, uploadFile, startServer, shutdownServer } from './utils.js';
const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
describe('users/notes', () => {
let p: childProcess.ChildProcess;
@ -15,8 +20,8 @@ describe('users/notes', () => {
before(async () => {
p = await startServer();
alice = await signup({ username: 'alice' });
const jpg = await uploadFile(alice, __dirname + '/resources/Lenna.jpg');
const png = await uploadFile(alice, __dirname + '/resources/Lenna.png');
const jpg = await uploadFile(alice, _dirname + '/resources/Lenna.jpg');
const png = await uploadFile(alice, _dirname + '/resources/Lenna.png');
jpgNote = await post(alice, {
fileIds: [jpg.id]
});