Insomnia v5 importer (#7)

Add support for the new Insomnia 5 export format
This commit is contained in:
Gregory Schier
2025-05-11 06:44:54 -07:00
committed by GitHub
parent 20b0b4fb69
commit 8c0f889dd2
10 changed files with 853 additions and 273 deletions
+11 -2
View File
@@ -1,6 +1,7 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { describe, expect, test } from 'vitest';
import YAML from 'yaml';
import { convertInsomnia } from '../src';
describe('importer-yaak', () => {
@@ -14,10 +15,18 @@ describe('importer-yaak', () => {
test('Imports ' + fixture, () => {
const contents = fs.readFileSync(path.join(p, fixture), 'utf-8');
const expected = fs.readFileSync(path.join(p, fixture.replace('.input', '.output')), 'utf-8');
const expected = fs.readFileSync(path.join(p, fixture.replace(/.input\..*/, '.output.json')), 'utf-8');
const result = convertInsomnia(contents);
// console.log(JSON.stringify(result, null, 2))
expect(result).toEqual(JSON.parse(expected));
expect(result).toEqual(parseJsonOrYaml(expected));
});
}
});
function parseJsonOrYaml(text: string): unknown {
try {
return JSON.parse(text);
} catch {
return YAML.parse(text);
}
}