From 5b421a8a094c8a08f15035d01486f2ddfc7fe177 Mon Sep 17 00:00:00 2001 From: Eugene Ghanizadeh Khoub Date: Fri, 5 Jan 2024 16:55:04 +0100 Subject: [PATCH] fix failed tests in CI? --- e2e/all.test.mjs | 5 --- e2e/{basic-test.mjs => basic.test.mjs} | 0 e2e/{glob-test.mjs => glob.test.mjs} | 0 e2e/{local-test.mjs => local.test.mjs} | 11 +++-- ...{readwrite-test.mjs => readwrite.test.mjs} | 0 e2e/{sanity-test.mjs => sanity.test.mjs} | 0 e2e/util.mjs | 7 +++- package-lock.json | 40 +++++++++++++++---- package.json | 1 + 9 files changed, 46 insertions(+), 18 deletions(-) delete mode 100644 e2e/all.test.mjs rename e2e/{basic-test.mjs => basic.test.mjs} (100%) rename e2e/{glob-test.mjs => glob.test.mjs} (100%) rename e2e/{local-test.mjs => local.test.mjs} (70%) rename e2e/{readwrite-test.mjs => readwrite.test.mjs} (100%) rename e2e/{sanity-test.mjs => sanity.test.mjs} (100%) diff --git a/e2e/all.test.mjs b/e2e/all.test.mjs deleted file mode 100644 index 7698181..0000000 --- a/e2e/all.test.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import './sanity-test.mjs' -import './basic-test.mjs' -import './glob-test.mjs' -import './readwrite-test.mjs' -import './local-test.mjs' diff --git a/e2e/basic-test.mjs b/e2e/basic.test.mjs similarity index 100% rename from e2e/basic-test.mjs rename to e2e/basic.test.mjs diff --git a/e2e/glob-test.mjs b/e2e/glob.test.mjs similarity index 100% rename from e2e/glob-test.mjs rename to e2e/glob.test.mjs diff --git a/e2e/local-test.mjs b/e2e/local.test.mjs similarity index 70% rename from e2e/local-test.mjs rename to e2e/local.test.mjs index ebc1cc4..be140f3 100644 --- a/e2e/local-test.mjs +++ b/e2e/local.test.mjs @@ -5,11 +5,14 @@ scenario('local', async (run, { ls, read }) => { await run('local:../template') expect(await ls()).toIncludeSameMembers([ '.tmplr.yml', 'halo.txt' ]) expect(await read('halo.txt')).toBe('Halo World!') -}, { root: 'target' }) +}, { + root: 'target', + skipCI: true, +}) scenario('local-use', async (run, { ls, read }) => { - await run('use', 'local:../recipe') - expect(await ls()).toIncludeSameMembers([ 'halo.txt' ]) + await run('use', 'local:./recipe') + expect(await ls()).toIncludeSameMembers([ 'halo.txt', 'recipe' ]) expect(await read('halo.txt')).toBe('Halo World!') -}, { root: 'target' }) +}) diff --git a/e2e/readwrite-test.mjs b/e2e/readwrite.test.mjs similarity index 100% rename from e2e/readwrite-test.mjs rename to e2e/readwrite.test.mjs diff --git a/e2e/sanity-test.mjs b/e2e/sanity.test.mjs similarity index 100% rename from e2e/sanity-test.mjs rename to e2e/sanity.test.mjs diff --git a/e2e/util.mjs b/e2e/util.mjs index 9950f49..4ccedc1 100644 --- a/e2e/util.mjs +++ b/e2e/util.mjs @@ -1,3 +1,6 @@ +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); + import { toIncludeSameMembers } from 'jest-extended' expect.extend({ toIncludeSameMembers }) @@ -11,8 +14,10 @@ export function scenario(name, testFn, options) { options ??= {} options.root ??= '.' + const fn = options.skipCI && require('ci-info').isCI ? test.skip : test + describe('scenario: ' + name, () => { - test('runs as expected', async () => { + fn('runs as expected', async () => { const fixsrc = name.split(':')[0] const fixture = join('e2e', 'fixtures', fixsrc) diff --git a/package-lock.json b/package-lock.json index c59a2e2..0c73d53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tmplr", - "version": "0.3.1", + "version": "0.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tmplr", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "dependencies": { "@tmplr/core": "^0.7.4", @@ -44,6 +44,7 @@ "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", "babel-jest": "^28.1.0", + "ci-info": "^4.0.0", "cross-env": "^7.0.3", "eslint": "^8.15.0", "eslint-plugin-jest-extended": "^2.0.0", @@ -3433,9 +3434,19 @@ } }, "node_modules/ci-info": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", - "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", + "integrity": "sha512-TdHqgGf9odd8SXNuxtUBVx8Nv+qZOejE6qyqiy5NtbYYQOeFa6zmHkxlPzmaLxWWHsU6nJmB7AETdVPi+2NBUg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } }, "node_modules/cjs-module-lexer": { "version": "1.2.2", @@ -5338,6 +5349,11 @@ "is-ci": "bin.js" } }, + "node_modules/is-ci/node_modules/ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" + }, "node_modules/is-core-module": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", @@ -11443,9 +11459,10 @@ "dev": true }, "ci-info": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", - "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", + "integrity": "sha512-TdHqgGf9odd8SXNuxtUBVx8Nv+qZOejE6qyqiy5NtbYYQOeFa6zmHkxlPzmaLxWWHsU6nJmB7AETdVPi+2NBUg==", + "dev": true }, "cjs-module-lexer": { "version": "1.2.2", @@ -12849,6 +12866,13 @@ "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", "requires": { "ci-info": "^2.0.0" + }, + "dependencies": { + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" + } } }, "is-core-module": { diff --git a/package.json b/package.json index 9499e23..fb5a47f 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", "babel-jest": "^28.1.0", + "ci-info": "^4.0.0", "cross-env": "^7.0.3", "eslint": "^8.15.0", "eslint-plugin-jest-extended": "^2.0.0",