How to use NewSuite method of watch Package

Best Ginkgo code snippet using watch.NewSuite

Run Ginkgo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

delta_tracker.go

Source: delta_tracker.go Github

copy
1package watch
2
3import (
4	"fmt"
5
6	"regexp"
7
8	"github.com/onsi/ginkgo/ginkgo/testsuite"
9)
10
11type SuiteErrors map[testsuite.TestSuite]error
12
13type DeltaTracker struct {
14	maxDepth      int
15	watchRegExp   *regexp.Regexp
16	suites        map[string]*Suite
17	packageHashes *PackageHashes
18}
19
20func NewDeltaTracker(maxDepth int, watchRegExp *regexp.Regexp) *DeltaTracker {
21	return &DeltaTracker{
22		maxDepth:      maxDepth,
23		watchRegExp:   watchRegExp,
24		packageHashes: NewPackageHashes(watchRegExp),
25		suites:        map[string]*Suite{},
26	}
27}
28
29func (d *DeltaTracker) Delta(suites []testsuite.TestSuite) (delta Delta, errors SuiteErrors) {
30	errors = SuiteErrors{}
31	delta.ModifiedPackages = d.packageHashes.CheckForChanges()
32
33	providedSuitePaths := map[string]bool{}
34	for _, suite := range suites {
35		providedSuitePaths[suite.Path] = true
36	}
37
38	d.packageHashes.StartTrackingUsage()
39
40	for _, suite := range d.suites {
41		if providedSuitePaths[suite.Suite.Path] {
42			if suite.Delta() > 0 {
43				delta.modifiedSuites = append(delta.modifiedSuites, suite)
44			}
45		} else {
46			delta.RemovedSuites = append(delta.RemovedSuites, suite)
47		}
48	}
49
50	d.packageHashes.StopTrackingUsageAndPrune()
51
52	for _, suite := range suites {
53		_, ok := d.suites[suite.Path]
54		if !ok {
55			s, err := NewSuite(suite, d.maxDepth, d.packageHashes)
56			if err != nil {
57				errors[suite] = err
58				continue
59			}
60			d.suites[suite.Path] = s
61			delta.NewSuites = append(delta.NewSuites, s)
62		}
63	}
64
65	return delta, errors
66}
67
68func (d *DeltaTracker) WillRun(suite testsuite.TestSuite) error {
69	s, ok := d.suites[suite.Path]
70	if !ok {
71		return fmt.Errorf("unknown suite %s", suite.Path)
72	}
73
74	return s.MarkAsRunAndRecomputedDependencies(d.maxDepth)
75}
76
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)