This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should not load
.txt
file (#40)
- Loading branch information
1 parent
283e3d7
commit ceae2b3
Showing
3 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from 'path'; | ||
import { testSuite, expect } from 'manten'; | ||
import { createFixture } from 'fs-fixture'; | ||
import type { NodeApis } from '../utils/node-with-loader.js'; | ||
|
||
export default testSuite(async ({ describe }, node: NodeApis) => { | ||
describe('Negative tests', ({ test }) => { | ||
test('should not load .txt files', async ({ onTestFinish }) => { | ||
const fixture = await createFixture({ | ||
'file.txt': 'Hello world', | ||
'index.js': 'import file from "./file.txt";console.log(file);', | ||
}); | ||
|
||
onTestFinish(async () => await fixture.rm()); | ||
|
||
const nodeProcess = await node.load(path.join(fixture.path, 'index.js')); | ||
expect(nodeProcess.stdout).toBe(''); | ||
expect(nodeProcess.stderr).toMatch('SyntaxError: Unexpected identifier'); | ||
}); | ||
}); | ||
}); |