Skip to content

Commit

Permalink
fix import error
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jun 17, 2024
1 parent 600b75d commit dcc9fc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"description": "A core plugin framework based on @eggjs/koa",
"scripts": {
"lint": "eslint src test --ext ts",
"pretest": "npm run prepublishOnly",
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "egg-bin test",
"preci": "npm run prepublishOnly",
"ci": "npm run lint && egg-bin cov && npm run prepublishOnly",
"contributor": "git-contributor",
"prepublishOnly": "tshy && tshy-after"
Expand Down
9 changes: 5 additions & 4 deletions test/loader/get_framework_paths.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { strict as assert } from 'node:assert';
import mm from 'mm';
import { importModule } from '@eggjs/utils';
import { Application, createApp, getFilepath } from '../helper.js';
import { EggLoader, EggCore } from '../../src/index.js';

Expand All @@ -15,7 +16,7 @@ describe('test/loader/get_framework_paths.test.ts', () => {

it('should get from framework using symbol', async () => {
app = createApp('eggpath', {
Application: (await import(getFilepath('framework-symbol/index.js'))).default,
Application: await importModule(getFilepath('framework-symbol/index.js'), { importDefaultOnly: true }),
});
assert.deepEqual(app.loader.eggPaths, [
getFilepath('egg'),
Expand All @@ -25,7 +26,7 @@ describe('test/loader/get_framework_paths.test.ts', () => {
});

it.skip('should throw when one of the Application do not specify symbol', async () => {
const AppClass = (await import(getFilepath('framework-nosymbol/index.js'))).default;
const AppClass = await importModule(getFilepath('framework-nosymbol/index.js'), { importDefaultOnly: true });
assert.throws(() => {
const app = createApp('eggpath', {
Application: AppClass,
Expand All @@ -36,7 +37,7 @@ describe('test/loader/get_framework_paths.test.ts', () => {

it('should remove dulplicate eggPath', async () => {
app = createApp('eggpath', {
Application: (await import(getFilepath('framework-dulp/index.js'))).default,
Application: await importModule(getFilepath('framework-dulp/index.js'), { importDefaultOnly: true }),
});
assert.deepEqual(app.loader.eggPaths, [
getFilepath('egg'),
Expand Down Expand Up @@ -71,7 +72,7 @@ describe('test/loader/get_framework_paths.test.ts', () => {
it('should assert eggPath type', async () => {
await assert.rejects(async () => {
createApp('eggpath', {
Application: (await import(getFilepath('framework-wrong-eggpath/index.js'))).default,
Application: await importModule(getFilepath('framework-wrong-eggpath/index.js'), { importDefaultOnly: true }),
});
}, /Symbol.for\('egg#eggPath'\) should be string/);
});
Expand Down

0 comments on commit dcc9fc2

Please sign in to comment.