Skip to content

Commit

Permalink
running tests one by one
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Duda committed Apr 11, 2024
1 parent d798111 commit f28568c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
- name: Configure git
run: git config --global init.defaultBranch main
- name: Make temporary folder for tests
run: mkdir ./TEST_TMP && ls -ltra .
run: mkdir ./__testModulesData__
- name: Run Jest unit tests
run: npm run test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"local-build": "npm run build && npm link",
"start": "npm run build && scope",
"tag": "npm run build && scope --tag-unpushed-commits",
"test": "jest ./test --verbose --silent=false",
"test": "jest ./test --verbose --silent=false --runInBand",
"clean": "rimraf .scope/"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion test/_utils/globals.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Common test constants

export const TEMP_TEST_FOLDER = "./TEST_TMP";
export const TEMP_TEST_FOLDER = "./__testModulesData__";
19 changes: 4 additions & 15 deletions test/_utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve, join } from "path";
import { existsSync, stat } from "fs";
import { existsSync } from "fs";
import { copySync } from "fs-extra";

import rimraf from "rimraf";
Expand Down Expand Up @@ -34,18 +34,7 @@ export const purgeMockRepository = () => {
// Temp folder

export const assertTemporaryFolderExists = () => {
stat(TEMP_TEST_FOLDER, function(err, stats) {
console.debug(stats);

if (!err) {
console.log('file or directory exists');
}
else if (err.code === 'ENOENT') {
console.log('file or directory does not exist');
}
});

// if (!existsSync(TEMP_TEST_FOLDER)) {
// throw new Error(`Temporary folder '${TEMP_TEST_FOLDER}' does not exist`);
// }
if (!existsSync(TEMP_TEST_FOLDER)) {
throw new Error(`Temporary folder '${TEMP_TEST_FOLDER}' does not exist`);
}
}
19 changes: 6 additions & 13 deletions test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
module.exports = async function(globalConfig, projectConfig) {
console.debug("\n[SCOPE TAGS] Global test setup");

const rimraf = require("rimraf");
const fs = require("fs");
const path = require("path");

global.TEMP_FOLDER_FOR_TESTS = path.resolve("./TEST_TMP/");

if (fs.existsSync(global.TEMP_FOLDER_FOR_TESTS)) {
// Just remove folder content
console.debug(`\n[SCOPE TAGS] Found existing temporary folder at '${global.TEMP_FOLDER_FOR_TESTS}', removing its contents...`);
// rimraf.sync(path.join(global.TEMP_FOLDER_FOR_TESTS, "*"));
return;
}
global.TEMP_FOLDER_FOR_TESTS = path.resolve("./__testModulesData__");

console.debug(`\n[SCOPE TAGS] Global test setup - initializing temporary folder at '${global.TEMP_FOLDER_FOR_TESTS}'...`);
try {
fs.mkdirSync(global.TEMP_FOLDER_FOR_TESTS, { recursive: true });
} catch (e) {
console.error(e);
if (!fs.existsSync(global.TEMP_FOLDER_FOR_TESTS)) {
console.debug(`[SCOPE TAGS] Initializing temporary folder at '${global.TEMP_FOLDER_FOR_TESTS}'...`);
fs.mkdirSync(global.TEMP_FOLDER_FOR_TESTS);
}
};
4 changes: 1 addition & 3 deletions test/teardown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module.exports = async function(globalConfig, projectConfig) {
console.debug(`[SCOPE TAGS] Global test teardown - initializing temporary folder at ${global.TEMP_FOLDER_FOR_TESTS}`);

console.debug(global.asdf);
console.debug(`[SCOPE TAGS] Global test teardown - removing temporary folder '${global.TEMP_FOLDER_FOR_TESTS}'`);

const rimraf = require("rimraf");
rimraf.sync(global.TEMP_FOLDER_FOR_TESTS);
Expand Down

0 comments on commit f28568c

Please sign in to comment.