Skip to content

Commit ddb0204

Browse files
committed
test: skip file system tests in WASI environment
1 parent 36a0399 commit ddb0204

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

__test__/index.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import test from 'ava'
22

33
import { search, searchFile, validatePattern, getSupportedFileTypes } from '../index.js'
44

5+
// Check if we're running in WASI environment
6+
const isWASI = process.env.NAPI_RS_FORCE_WASI === '1'
7+
58
test('validate pattern function', (t) => {
69
t.true(validatePattern('hello'))
710
t.true(validatePattern('\\d+'))
@@ -16,7 +19,13 @@ test('get supported file types function', (t) => {
1619
t.true(types.includes('javascript'))
1720
})
1821

19-
test('search function with basic pattern', async (t) => {
22+
test('search function with basic pattern', (t) => {
23+
if (isWASI) {
24+
// In WASI environment, skip file system tests
25+
t.pass('Skipping file system test in WASI environment')
26+
return
27+
}
28+
2029
// Search for 'use' in the current source file
2130
const result = search('use', ['./src/lib.rs'])
2231

@@ -27,7 +36,13 @@ test('search function with basic pattern', async (t) => {
2736
t.true(Array.isArray(result.matches))
2837
})
2938

30-
test('search file function', async (t) => {
39+
test('search file function', (t) => {
40+
if (isWASI) {
41+
// In WASI environment, skip file system tests
42+
t.pass('Skipping file system test in WASI environment')
43+
return
44+
}
45+
3146
// Search for 'fn' in the source file
3247
const result = searchFile('fn', './src/lib.rs')
3348

0 commit comments

Comments
 (0)