javascript-testing-best-practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2025)
- 25k
- JavaScript
- MIT
- 2 y ago
Testing Sublime Text Packages
Repo SublimeText/UnitTesting, read from GitHub 12 min ago. SublimeText has not joined Take My Repo.
SublimeText/UnitTesting is a public repo on GitHub by SublimeText. Testing Sublime Text Packages. It declares the MIT license on GitHub. It is written mainly in Python, has 113 stars and last changed on 2026-10-29. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-22.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
This is a unittest framework for Sublime Text. It runs unittest testcases on local machines and via Github Actions. It also supports testing syntax_test files for the new sublime-syntax format and sublime-color-scheme files.
test*.py under the directory tests
(configurable, see below). The testcases are then loaded by TestLoader.discover.Here are some small examples
Command Palette using ctrl+shift+P or menu item Tools → Command Palette...Unittesting: ... command to run and hit EnterTo test any package...
UnitTesting: Test Package An output panel pops up displaying progress and results of running tests.
To run only tests in particular files, enter <Package name>:<filename>.
<filename> should be a unix shell wildcard to match the file names.
<Package name>:test*.py is used by default.
The command UnitTesting: Test Current Package runs all tests
of the current package the active view's file is part of.
The package is reloaded to pickup any code changes and then tests are executed.
The command UnitTesting: Test Current Package with Coverage
runs tests for current package and generates a coverage report via coverage.
The .coveragerc file is used to control coverage configurations.
If it is missing, UnitTesting will ignore the tests directory.
[!NOTE]
As of Unittesting 1.8.0 the following commands have been replaced to enable more flexible usage and integration in build systems.
unit_testing_current_package
{ "command": "unit_testing", "package": "$package_name" }unit_testing_current_file
{ "command": "unit_testing", "package": "$package_name", "pattern": "$file_name" }
To run tests via build system specify unit_testing build system "target".
{
"target": "unit_testing"
}
Test Current Package build commandIt is recommended to add the following to .sublime-project file so that ctrl+b would invoke the testing action.
"build_systems":
[
{
"name": "Test Current Package",
"target": "unit_testing",
"package": "$package_name",
"failfast": true
}
]
Test Current File build commandIt is recommended to add the following to .sublime-project file so that ctrl+b would invoke the testing action.
"build_systems":
[
{
"name": "Test Current File",
"target": "unit_testing",
"package": "$package_name",
"pattern": "$file_name",
"failfast": true
}
]
To run tests without affecting your interactive Sublime Text session,
use the bundled docker/ut-run-tests launcher.
# run all tests from current package root
/path/to/UnitTesting/docker/ut-run-tests .
# run just one test file (faster)
/path/to/UnitTesting/docker/ut-run-tests . --file tests/test_example.py
If UnitTesting/docker is on your PATH, you can simply run:
ut-run-tests .
This launcher calls docker/run_tests.py, which runs tests in a Docker
container (headless), streams output to stdout/stderr and keeps a cache
volume so repeated runs are fast. By default it runs Python unit tests,
syntax tests and syntax compatibility checks.
--file chooses the runner from the selected file: Python files run as unit
tests, syntax_test* files run as syntax tests, and .sublime-syntax files
run compatibility checks.
Useful options:
--file tests/test_foo.py--pattern test_foo.py --tests-dir tests/subdir--no-unit-tests--no-syntax-tests--no-syntax-compatibility-checks--coverage--failfast--reload-package-on-testing (default: off)--scheduler-delay-ms 0 (default)--dry-run (only print runtime metadata and schedule)--refresh-cache (re-bootstrap cached /root state)--refresh-image (rebuild local Docker image)--refresh (both cache and image refresh)--no-cache-volume (run without persistent cache)--lock-timeout SECONDS (wait for shared cache-volume lock)--no-lock (disable cache-volume serialization; unsafe if shared)[!TIP]
This is useful for editor build systems and for AI agents, because test runs no longer commandeer your active editor window.
You can also add the headless runner as build system:
"build_systems":
[
{
"name": "Test Package (Docker)",
"shell_cmd": "\"${packages}\\UnitTesting\\docker\\ut-run-tests.cmd\" .",
"working_dir": "$project_path",
"file_regex": "^\\s*File \"/root/\\.config/sublime-text/Packages/[^/]+/(.+)\", line ([0-9]+)",
},
{
"name": "Test Current File (Docker)",
"shell_cmd": "\"${packages}\\UnitTesting\\docker\\ut-run-tests.cmd\" . --file \"${file}\"",
"working_dir": "$project_path",
"file_regex": "^\\s*File \"/root/\\.config/sublime-text/Packages/[^/]+/(.+)\", line ([0-9]+)",
}
]
Unittesting provides the following GitHub Actions, which can be combined in a workflow to design package tests.
SublimeText/UnitTesting/actions/setup
Setup Sublime Text to run tests within.
This must always be the first step after checking out the package to test.
SublimeText/UnitTesting/actions/run-color-scheme-tests
Test color schemes using ColorSchemeUnit.
SublimeText/UnitTesting/actions/run-syntax-tests
Test sublime-syntax definitions using built-in syntax test functions of already running Sublime Text environment.
It is an alternative to SublimeText/syntax-test-action or sublimehq's online syntax_test_runner
SublimeText/UnitTesting/actions/run-tests
Runs the unit_testing command to perform python unit tests.
[!NOTE]
actions are released in the branch
v1. Minor changes will be pushed to the same branch unless there are breaking changes.
To integrate color scheme tests via ColorSchemeUnit
add the following snippet to a workflow file
(e.g. .github/workflows/color-scheme-tests.yml).
name: ci-color-scheme-tests
on: [push, pull_request]
jobs:
run-syntax-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: SublimeText/UnitTesting/actions/setup@v1
- uses: SublimeText/UnitTesting/actions/run-color-scheme-tests@v1
To run only syntax tests add the following snippet to a workflow file
(e.g. .github/workflows/syntax-tests.yml).
name: ci-syntax-tests
on: [push, pull_request]
jobs:
run-syntax-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: SublimeText/UnitTesting/actions/setup@v1
- uses: SublimeText/UnitTesting/actions/run-syntax-tests@v1
[!NOTE]
If you are looking for syntax tests only, you may also checkout SublimeText/syntax-test-action. Using this test makes most sense to just re-use an already set-up ST test environment.
To run only python unit tests on all platforms and versions of Sublime Text
add the following snippet to a workflow file (e.g. .github/workflows/unit-tests.yml).
name: ci-unit-tests
on: [push, pull_request]
jobs:
run-tests:
strategy:
fail-fast: false
matrix:
st-version: [3, 4]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: SublimeText/UnitTesting/actions/setup@v1
with:
package-name: Package Name # if differs from repo name
sublime-text-version: ${{ matrix.st-version }}
- uses: SublimeText/UnitTesting/actions/run-tests@v1
with:
coverage: true
package-name: Package Name # if differs from repo name
- uses: codecov/codecov-action@v4
name: ci-tests
on: [push, pull_request]
jobs:
run-tests:
strategy:
fail-fast: false
matrix:
st-version: [3, 4]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
# checkout package to test
- uses: actions/checkout@v4
# setup test environment
- uses: SublimeText/UnitTesting/actions/setup@v1
with:
sublime-text-version: ${{ matrix.st-version }}
extra-packages: |
A File Icon:SublimeText/AFileIcon
# run color scheme tests (only on Linux)
- if: ${{ matrix.os == 'ubuntu-latest' }}
uses: SublimeText/UnitTesting/actions/run-color-scheme-tests@v1
# run syntax tests and check compatibility with new syntax engine (only on Linux)
- if: ${{ matrix.os == 'ubuntu-latest' }}
uses: SublimeText/UnitTesting/actions/run-syntax-tests@v1
with:
compatibility: true
# run unit tests with coverage upload
- uses: SublimeText/UnitTesting/actions/run-tests@v1
with:
coverage: true
- uses: codecov/codecov-action@v4
extra-packages takes one package per line, in one of these forms:
user/repo@ref or Package Name:user/repo@ref clones the package from GitHub.
@ref is a branch, a tag or a tag prefix (e.g. st3-). Without it, the latest x.y.z tag is used.Package Name (no /) lets Package Control install the package,
picking the latest release compatible with the Sublime Text build.
Requires install-package-control: true (the default).Check this for further examples.
UnitTesting is primarily configured by unittesting.json file in package root directory.
{
"verbosity": 1,
"coverage": true
}
Options provided via build system configuration override unittesting.json.
{
"target": "unit_testing",
"package": "$package_name",
"verbosity": 2,
"coverage": true
}
Options passed as arguments to unit_testing command override unittesting.json.
window.run_command("unit_testing", {"package": "$package_name", "coverage": False})
| name | description | default value |
|---|---|---|
| tests_dir | the name of the directory containing the tests | "tests" |
| pattern | the pattern to discover tests | "test*.py" |
| deferred | whether to use deferred test runner | true |
| condition_timeout | default timeout in ms for callables invoked via yield |
4000 |
| failfast | stop early if a test fails | false |
| output | name of the test output instead of showing in the panel |
null |
| verbosity | verbosity level | 2 |
| warnings | The warnings filter controls python warnings treatment. | "default" |
| capture_console | capture stdout and stderr in the test output | false |
| reload_package_on_testing | reloading package will increase coverage rate | true |
| coverage | track test case coverage | false |
| coverage_on_worker_thread | (experimental) | false |
| generate_html_report | generate HTML report for coverage | false |
| generate_xml_report | generate XML report for coverage | false |
Valid warnings values are:
| Value | Disposition |
|---|---|
| "default" | print the first occurrence of matching warnings for each location (module + line number) where the warning is issued |
| "error" | turn matching warnings into exceptions |
| "ignore" | never print matching warnings |
| "always" | always print matching warnings |
| "module" | print the first occurrence of matching warnings for each module where the warning is issued (regardless of line number) |
| "once" | print only the first occurrence of matching warnings, regardless of location |
see also: https://docs.python.org/3/library/warnings.html#warning-filter
UnitTesting is based on python's unittest library.
Any valid unittest test case is allowed.
Module lookup and imports respect Sublime Text's package ecosystem. Global imports lookup modules in:
${data}/sublime-text/Lib/python38/${data}/sublime-text/Packages/${install}/Packages/A common ST package's folder structure may look like this:
Packages
├── ...
└── Package To Test
├── sub_package
| ├── __init__.py
| └── module.py
├── tests
| ├── __init__.py
| └── test_module.py
└── plugin.py
The Package To Test is the root package being tested,
which contains tests/ as a sub-package,
next to primary business logic in sub_package.
This differs from how normal python package repositories organize tests next to package's source folder.
It requires package name (Package To Test) to be included in all absolute module names.
[!NOTE]
ST packages don't need and should not contain a top-level
__init__.pymodule to be treated like a normal python package.
Test cases can use relative imports to access all modules.
Example:
Package To Test/tests/test_module.py
from unittest.mock import patch
from unittesting import TestCase
from ..sub_package.module import ClassToTest
class MyTestCase(TestCase):
def test_something(self):
obj = ClassToTest()
self.assertTrue(obj.some_method() == True)
def test_with_mock(self):
# need absolute module name including ST package here
with patch("Package To Test.sub_package.module") as mock:
...
Tests can be written using deferrable test cases to test results of asynchronous or long lasting sublime commands, which require yielding control to sublime text runtime and resume test execution at a later point.
It is a kind of cooperative multithreading such as provided by asyncio,
but with a home grown DeferringTextTestRunner acting as event loop.
The idea was inspired by Plugin UnitTest Harness.
DeferrableTestCase is used to write the test cases. They are executed by the DeferringTextTestRunner and the runner expects not only regular test functions, but also generators. If the test function is a generator, it does the following
if the yielded object is a callable, the runner will evaluate the
callable and check its returned value. If the result is not None,
the runner continues the generator, if not, the runner will wait until the
condition is met with the default timeout of 4s. The result of the callable
can be also retrieved from the yield statement. The yielded object could
also be a dictionary of the form
{
# required condition callable
"condition": callable,
# system timestamp when to start condition checks (default: `time.time()`)
"start_time": timestamp,
# optional the interval to invoke `condition()` (default: 17)
"period": milliseconds,
# optional timeout to wait for condition to be met (default: value from unittesting.json or 4000)
"timeout": milliseconds,
# optional message to print, if condition is not met within timeout
"timeout_message": "Condition not fulfilled"
}
to specify various overrides such as poll interval or timeout in ms.
if the yielded object is an integer, say x, then it will continue the
generator after x ms.
yield AWAIT_WORKER would yield to a task in the worker thread.
otherwise, a single yield would yield to a task in the main thread.
Example:
import sublime
from unittesting import DeferrableTestCase
class TestCondition(DeferrableTestCase):
def test_condition1(self):
x = []
def append():
x.append(1)
def condition():
return len(x) == 1
sublime.set_timeout(append, 100)
# wait until `condition()` is true
yield condition
self.assertEqual(x[0], 1)
def test_condition2(self):
x = []
def append():
x.append(1)
def condition():
return len(x) == 1
sublime.set_timeout(append, 100)
# wait until `condition()` is true
yield {
"condition": condition,
"period": 200,
"timeout": 5000,
"timeout_message": "Not enough items added to x"
}
self.assertEqual(x[0], 1)
see also tests/test_defer.py.
Tests for asyncio use AsyncTestCase or AsyncViewTestCase class.
It auto-detects type of setUp(), tearDown(), and test_..() methods.
Those can be synchronous methods or async coroutine functions.
Asynchronous coroutine functions are executed in default event loop, provided by sublime_aio.
import asyncio
import sublime
from unittesting import AsyncTestCase
async def async_coroutine(view):
def run_in_mainthread():
view.run_command("select_all")
view.run_command("right_delete")
view.run_command("insert", {"characters": "Modified Content"})
sublime.set_timeout(run_in_mainthread, 10)
await asyncio.sleep(2.0)
class MyAsyncTestCase(AsyncTestCase):
timeout_ms = 4000
"""Class wide coroutine timeout."""
@classmethod
async def setUpClass(cls):
pass
@classmethod
async def tearDownClass(cls):
pass
async def setUp(self):
self.view = sublime.active_window().new_file()
self.view.set_scratch(True)
self.view.run_command("insert", {"characters": "Initial Content"})
async def tearDown(self):
self.view.close()
async def test_setup_completed(self):
self.assertEqual(
self.view.substr(sublime.Region(0, self.view.size())),
"Initial Content"
)
async def test_coroutine(self, timeout_ms=10000):
"""
A long running coroutine with custom timeout.
"""
await async_coroutine(self.view)
self.assertEqual(
self.view.substr(sublime.Region(0, self.view.size())),
"Modified Content"
)
To run coroutines in a custom event loop, override static run_override() method.
import collections.abc
import concurrent.futures
import sublime_aio
from unittesting import AsyncTestCase
class MyAsyncTestCase(AsyncTestCase):
def run_coroutine(coro: collections.abc.Coroutine) -> cuncurrent.futures.Future:
return sublime_aio.run_coroutine(coro)
Note, asyncio event loops must not block Sublime Text's main thread.
[!WARNING]
Do not use
unittest.IsolatedAsyncioTestCaseclass, as it spins up a blocking event loop in main thread, which prevents any synchronous command from being executed by Sublime Text.
UnitTesting provides some helper test case classes, which perform common tasks such as overriding preferences, setting up views, etc.
Usage and some examples are available via docstrings, which are displayed as hover popup by LSP and e.g. LSP-pyright.
Thanks guillermooo and philippotto for their early efforts in AppVeyor and Travis CI macOS support (though these services are not supported now).
SublimeText/UnitTesting is a public repo on GitHub by SublimeText. Testing Sublime Text Packages.
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-10-29. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.

📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2025)
Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites

macOS development environment setup: Easy-to-understand instructions with automated setup scripts for developer tools like Vim, Sublime Text, Bash, iTerm, Python data analysis, Spark, Hadoop MapReduce, AWS, Heroku, JavaScript web development, Android development, common data stores, and dev-based OS X defaults.

Split the window however you like! Create new panes, delete panes, move and clone views from pane to pane.
This page is also available as structured data, with the same sources and dates.
Take My Repo has not tested this on your machine. Requirements come from the project's own documentation.