2019-01-12 20:21:43 +00:00
|
|
|
import { importModule } from '../../src/imports'
|
|
|
|
|
|
|
|
describe('imports', () => {
|
|
|
|
test('should import relative module', async () => {
|
|
|
|
await expect(importModule('jest')).resolves.toBeDefined()
|
|
|
|
})
|
|
|
|
test('should import core module', async () => {
|
|
|
|
await expect(importModule('path')).resolves.toBeDefined()
|
|
|
|
})
|
2019-04-07 10:25:53 +00:00
|
|
|
test('should throw error with proper code when module not found', async () => {
|
|
|
|
await expect(importModule('not-found-module')).rejects.toMatchObject({
|
2019-11-26 22:42:39 +00:00
|
|
|
message: 'Cannot import module \'not-found-module\'',
|
2019-04-07 10:25:53 +00:00
|
|
|
code: 'MODULE_NOT_FOUND'
|
|
|
|
})
|
2019-01-12 20:21:43 +00:00
|
|
|
})
|
|
|
|
test('should throw error when error is not module not found', async () => {
|
|
|
|
await expect(importModule('jest/README.md')).rejects.toThrow()
|
|
|
|
})
|
|
|
|
})
|